The Spring Integration team has come up with a DSL where the prominent parts of the EIP become verbs in the DSL. Take this example:
val messageFlow = filter.using{payload:String => payload == "hello"} --> transform.using { m: Message[String] => m.getPayload().toUpperCase() } --> handle.using { m: Message[_] => println(m) }
Notice the example's simple use of "filter", "transform", and "handle", with other verbs like "split", "aggregate", "enrich", "enrich.header", and "route" existing as well. The DSL makes heavy use of the Pipes and Filters pattern so that flows are that much more readable. I imagine you could create more complex flows by ending one flow with "someChannelName.send()" to feed messages into other channels.
val messageFlow = filter.using{payload:String => payload == "hello"} --> transform.using { m: Message[String] => m.getPayload().toUpperCase() } --> handle.using { m: Message[_] => nextFlow.send(m) }
Scala as a language can make for some very elegant code with minimal intrusion of the language itself. Using it as a DSL makes a lot of sense.
You can find the the announcement at the SpringSource blog and the DSL Reference on the Spring website.
No comments:
Post a Comment