Engineering
Releases
News and Events

Introducing Spring Integration Scala DSL

Introduction

The Spring Integration team is happy to announce the first milestone release (1.0.0.M1) of the Spring Integration Scala DSL - one of the newest additions to Spring Integration portfolio.

What is the Spring Integration Scala DSL?

The Spring Integration Scala DSL is a Domain Specific Language written in Scala with the goals of:

    • providing a strongly-typed alternative to XML configuration for Spring Integration
    • raising awareness about Spring Integration in Scala community
    • providing first class integration with various Scala frameworks and products such as Akka
    • providing seamless integration with Java where Scala developers can still leverage their existing Java investments

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.

Show me

Here is a quick glimpse into the DSL itself:

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.

Screen-casts

To help you along the way we have also released 2 screen-casts.

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]

Roadmap

The initial project road-map is available here

Feedback

Let us know what you think by using Spring Integration Forums and Spring Integration Scala DSL JIRA or by posting your comments here.

comments powered by Disqus