Spring Integration 3.0.2 and 4.0 Milestone 4 Released

Releases | Artem Bilan | March 31, 2014 | ...

We are pleased to announce the final milestone release towards Spring Integration 4.0 and the next maintenance release for the 3.0.x stream. The 3.0.2.RELEASE contains a small number of important fixes for the 3.0 release. Spring Integration 3.0 users are encouraged to upgrade to this release as soon as possible. Please see the 3.0.2 release notes and project page for more information.

Spring Integration 4.0 is the next generation of the framework, which is now based on the new Spring Framework 4.0 Messaging Module. See the Migration Guide for information about migrating applications from Spring Integration 3.0 to 4.0.

Another main goal of the Spring Integration 4.0 release is the addition of improved Java and annotation configuration capabilities to the framework; let's shed light on some of them...


Spring Integration provides a number of environment and built-in beans to support the runtime Enterprise Integration Patterns and Messaging infrastructure. With XML configuration, they are automatically declared as necessary by NamespaceHandlers. In a pure Java-only configuration, there is no namespace handler and another mechanism is required to set up the Integration environment. The @EnableIntegration annotation has been added for this purpose. It is similar to @EnableWebMvc from spring-webmvc or @Enable*Repositories annotations from Spring Data and should be placed alongside a @Configuration annotation on at least one class.

Note, It's only necessary to have one @EnableIntegration annotation in the ApplicationContext. With the annotation in place, you can start to configure integration flows from Spring @Configuration classes:

public static class MyConfiguration {

    public MessageChannel fileWritingChannel() {
         return new DirectChannel();

    public FileWritingMessageHandler fileWritingMessageHandler() {
        return new FileWritingMessageHandler(this.outputDir);

    public ConsumerEndpointFactoryBean fileWritingEndpoint() {
        ConsumerEndpointFactoryBean endpoint = new ConsumerEndpointFactoryBean();
        return endpoint;


Of course, with component scanning, the existing Spring Integration configuration annotations (@MessageEndpoint, @ServiceActivator, @Router, @Filter etc.) can be used to define the flow. See the Spring Boot application later in this post for an example.


Another useful and important Messaging component is the Messaging Gateway. With XML we use the <int:gateway/> component to provide an implementation of an interface as a Gateway to the Messaging flow. With Spring Integration 4.0 you can avoid XML configuration by using the new @MessagingGateway annotation that has been introduced. This annotation provides the same attributes as the <int:gateway/> element and is placed on gateway's service interface:

@MessagingGateway(defaultRequestChannel = "gatewayChannel",
     defaultHeaders = @GatewayHeader(name = "foo", value = "FOO"))
public interface MyGateway {

	@Gateway(headers = @GatewayHeader(name = "calledMethod",
                                      expression = "#gatewayMethod.name"))
	String echo(String payload);


Important: since this component isn't visible to the Spring container automatically and the default @ComponentScan doesn't work with interfaces, another new annotation @IntegrationComponentScan has been introduced. This annotation is similar to @Enable*Repositories from Spring Data and provides options to configure a basePackages property to scan integration components and should be placed alongside with @Configuration.

Spring Boot @EnableAutoConfiguration

Utilizing the SpringFactoriesLoader mechanism, the Spring Integration infrastructure is also available via the Spring Boot @EnableAutoConfiguration annotation. Simply add Spring Integration 4.0 to the classpath and use the Spring Boot Auto Configuration features.

Here's a very simple Spring Boot application:

@EnableAutoConfiguration  // enables integration infrastructure
@IntegrationComponentScan // looks for gateways
@ComponentScan			  // looks for Spring Beans
public class Integration {

	public static void main(String[] args) throws Exception {
		ConfigurableApplicationContext ctx = SpringApplication.run(Integration.class, args);
		String reply = ctx.getBean(GW.class).sendAndReceive("foo");

	public interface GW {

		String sendAndReceive(String payload);

	public static class MyService {

		public String foo(String payload) {
			return payload.toUpperCase();


Other changes

In addition, other useful and convenient components for Java and Annotation configuration have been introduced: @EnableMessageHistory, @EnablePublisher, @EnableIntegrationMBeanExport, @GlobalChannelInterceptor, @IntegrationConverter etc. For information about new features and changes see the What's New and release notes of the Spring Integration 4.0 Milestone 4.

For a complete list of changes in Spring Integration 4.0 refer to the release notes for each milestone:

(the first milestone was simply refactoring the 3.0 code to use spring-messaging classes).

The 4.0.0.M4 release is available in the Spring milestone repository now.

We look forward to receiving your comments and feedback: Spring Forum, StackOverflow(spring-integration tag), Spring JIRA!


Spring Integration Java DSL coming soon!

Get the Spring newsletter

Thank you!

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all