6 Replies Latest reply on Apr 20, 2007 7:56 AM by Kevin Conner

    Groovy Scripted Gateways... Useful for testing... and more p

    Tom Fennelly Master

      I was playing around with some Groovy scripts for doing some Groovy SOAP using the GroovyActionProcessor.

      I got fed up redeploying .esbs and restarting the AS, so I wanted a way of updating the Groovy script run by the GroovyActionProcessor without redeploying or restarting.

      The answer was a new gateway which can run Groovy scripts. Effectively, the Groovy script becomes the gateway. With this I was able write a really simple Groovy Scripted Gateway that popped up a Swing form through which I could deliver a message payload to the target service - in this case, a Groovy script. So I now had a convenient way of modifying the script, on the fly, with no need for redeploys or restarts. Useful for testing. See the flash.

      So the esb config for running this Gateway Script (bundled in the product) is as follows (listeners and actions only):

       <groovy-listener name="soap-client" script="MessageInjectionConsole" is-gateway="true" />
       <jms-listener name="JMS-Helper-ESBListener" busidref="GroovyService"/>
       <action name="groovy" class="org.jboss.soa.esb.actions.scripting.GroovyActionProcessor" />

      Note the groovy-listener listener element.

      This particular Groovy Gateway script is here. Note how simple it is. It uses a UncomposedMessageDeliveryAdapter instance (available to all Gateway sctips) to deliver the message to the target service, async or sync.

      You could write Groovy scripted Gateways to do all sorts of other stuff too e.g. Groovy and XFire are tightly integrated => you could stand up an XFire Gateway in a few lines of code (in theory - according to the Groovy website).