Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreWhat is the Spring Integration Scala DSL?
The Spring Integration Scala DSL is a Domain Specific Language written in Scala with the goals of:
One thing we would like to point out is that the Spring Integration Scala DSL is not itself a new EIP framework. Rather, it's a Scala-based DSL that sits on top of the Java-based Spring Integration framework, and, in the first milestone, the DSL itself still relies heavily on Java types from the Spring Integration API. However, as it progresses through subsequent milestones, the DSL will evolve to become increasingly Scala-esque. We do believe that such close integration with the existing java API provides instant reusability, but we also recognize the benefit of providing Scala wrappers and converters over those types in the future.
val messageFlow =
filter{payload: String => payload == "World"} -->
transform{ payload: String => "Hello " + payload} -->
handle{ payload: String => println(payload) }
messageFlow.send("World")
. . . and that is all!
Compare this to its Java/XML equivalent:
XML Configuration (config.xml):
<int:gateway service-interface="foo.bar.MyGateway"
default-request-channel="inChannel"/>
<int:filter input-channel="inChannel"
expression="payload.equals('World')"
output-channel="transformingChannel"/>
<int:transformer input-channel="transformingChannel"
expression="'Hello ' + payload"
output-channel="loggingChannel"/>
<int:service-activator input-channel="loggingChannel"
expression="T(java.lang.System).out.println(payload)"/>
Java:
public class SpringIntegrationIntro {
public static void main(String... strings ){
ApplicationContext context =
new ClassPathXmlApplicationContext("config.xml");
MyGateway gateway = context.getBean(MyGateway.class);
gateway.send("World");
}
public static interface MyGateway {
public void send(String value);
}
}
The first and perhaps obvious thing you should notice is how much quicker it is to wire something like this using the Scala DSL. But that is not the only benefit. Strong typing and the ability to benefit from other features of a functional language like Scala (e.g., using Scala functions as message processors) are just a few to mention. You can get more information and details from the project's GitHub website which contains a comprehensive Introduction as well as How to get started, DSL Reference and more.
The first screen-cast is a short (~15 min) introduction to Spring Integration Scala DSL which also covers the ideas and motivation behind the project - [Intro-SI-Scala.mov]
Another screen-cast (~10 min) is a visual supplement to How to get Started with Spring Integration Scala DSL which includes a demonstration on how to get started with Eclipse based development environment, as well as IntelliJ IDEA. - [Getting-Started-SI-Scala.mov]