Monday, October 15, 2007

Using Groovy to do a simple Synapse DSL

I've been playing with Groovy and Synapse. If you want to know more - come along to my talk at the Grails Exchange on Friday.

One of the things I've done is to use the StreamingMarkupBuilder to turn the Synapse configuration into a nice {curly bracket} language from its nasty <angle bracket>!

Here is an example:

definitions {
task(class:"MessageInjector", name:"messageInjector1") {
trigger(interval:"5000")
property(name:"message") {
blah { mydata() }
}
property(name:"to",value:"urn:paul")
}
"in" {
log(level:"full")
send()
}
out {
send()
}
}

A simple Groovy script converts this into a synapse.xml. A next step will be to directly build the Synapse mediator tree from this syntax instead. But in the meantime this is a nice hack, and not bad for 16 lines of code!

Paul

3 Comments:

Blogger tog said...

Hi Paul,
I saw the video on TSS. Would it be possible to make the slides available ?
Cheers
Guillaume

11:48 PM  
Blogger Unknown said...

Yes I've posted the slides here:
http://svn.apache.org/repos/asf/webservices/synapse/trunk/java/src/site/resources/presentations/makingsoagroovyfremantle.pdf

11:58 PM  
Blogger Unknown said...

And I'm saying it again here because the last comment wasn't readable!

https://svn.apache.org/repos/asf/webservices/synapse/trunk/java/src/site/resources/presentations/makingsoagroovyfremantle.pdf

11:59 PM  

Post a Comment

<< Home