Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreThe Spring Integration development team is pleased to announce the release of the First Milestone of the Java DSL extension for Spring Integration!
The general purpose of the Java DSL is to provide a fluent and convenient API for Message Flows based on EIP and avoid boilerplate Spring Integration configuration.
The org.springframework.integration:spring-integration-java-dsl:1.0.0.M1
artifact is available from the
Spring IO Milestone Repository.
You can find in more information in the Reference Manual and from source code, however let us shed some light on the main features.
The Concept
The Spring Integration Java DSL is not similar to existing Scala and Groovy DSls; nor is it similar to the Apache Camel Java DSL, although it does implement the method-chain principle.
Our main goal is to reuse existing practices from the Spring Framework JavaConfig (@Configuration
classes), as well from Spring Integration Core
components. To achieve the method-chain principle, we provide a set of builders and their factories.
Also Java 8 Lambdas provide some additional assistance for clean syntax.
The Basics
The central class is IntegrationFlows
- the IntegrationFlowBuilder
factory, - which should be used from a @Bean
definition method to populate the IntegrationFlow
bean using method-chains and Lambdas as parameters. The IntegrationFlowBuilder
provides a lot of
overloaded methods to configure Integration Endpoints. We call them EIP-methods. The canonical sample:
@Bean
public IntegrationFlow helloWorldFlow() {
return IntegrationFlows.from("helloWorldInput")
.filter("World"::equals)
.transform("Hello "::concat)
.handle(System.out::println)
.get();
}
Using Spring Integration terms the description for the sample above is:
Message
is sent to the "helloWorldInput" channel;filter
accepts it only if its payload
is the String "World";transformer
prefixes the payload
with Hello
;handler
prints the result to the STDOUT;payload
isn't "World", we won't see anything in the console - the Message
is discarded byfilter
.
The Spring Integration Java DSL can be used in existing applications as is, and can be wired with exising Messaging Annotations configuration or Spring Integration XML configuration, and, of course, in Spring Boot applications.
Plesae refer to the Reference Manual mentioned above for more information.
Wrapping up
This is just the beginning and we are working on an appropriate solution to configure protocol-specific adapters
using similar fluent API and Lambdas. Please don't hesitate to share your thoughts and feedback:
Spring Forum,
StackOverflow (spring-integration
tag), Spring JIRA.
Webinar: Spring Integration 4.0
Don't miss the Webinar with Gary Russell demonstrating new features from Spring Integration 4.0!
SpringOne 2GX 2014 is around the corner
Book your place at SpringOne in Dallas, TX for Sept 8-11 soon. It's simply the best opportunity to find out first hand all that's going on and to provide direct feedback. Expect a number of significant new announcements this year. We are anticipating that several in-depth Spring-Integration sessions will be presented.