2. What’s new in Spring Integration 5.0?

This chapter provides an overview of the new features and improvements that have been introduced with Spring Integration 5.0. If you are interested in more details, please see the Issue Tracker tickets that were resolved as part of the 5.0 development process.

2.1 New Components

2.1.1 Java DSL

The separate Spring Integration Java DSL project has now been merged into the core Spring Integration project. The IntegrationComponentSpec implementations for channel adapters and gateways are distributed to their specific modules. See Chapter 9, Java DSL for more information about Java DSL support. Also see the 4.3 to 5.0 Migration Guide for the required steps to move to Spring Integration 5.0.

2.1.2 Testing Support

A new Spring Integration Test Framework has been created to assist with testing Spring Integration applications. Now, with the @SpringIntegrationTest annotation on test class and MockIntegration factory you can make your JUnit tests for integration flows somewhat easier.

See Appendix F, Testing support for more information.

2.1.3 MongoDB Outbound Gateway

The new MongoDbOutboundGateway allows you to make queries to the database on demand by sending a message to its request channel.

See Section 23.6, “MongoDB Outbound Gateway” for more information.

2.1.4 WebFlux Gateways and Channel Adapters

The new WebFlux support module has been introduced for Spring WebFlux Framework gateways and channel adapters.

See Chapter 34, WebFlux Support for more information.

2.1.5 Content Type Conversion

Now that we use the new InvocableHandlerMethod -based infrastructure for service method invocations, we can perform contentType conversion from payload to target method argument.

See Section 8.1.7, “Content Type Conversion” for more information.

2.1.6 ErrorMessagePublisher and ErrorMessageStrategy

The ErrorMessagePublisher and the ErrorMessageStrategy are provided for creating ErrorMessage instances.

See Section E.4, “Error Handling” for more information.

2.1.7 JDBC Metadata Store

A JDBC implementation of MetadataStore implementation is now provided. This is useful when it is necessary to ensure transactional boundaries for metadata.

See Section 19.7, “JDBC Metadata Store” for more information.

2.2 General Changes

Spring Integration is now fully based on Spring Framework 5.0 and Project Reactor 3.1. Previous Project Reactor versions are no longer supported.

2.2.1 Core Changes

The @Poller annotation now has the errorChannel attribute for easier configuration of the underlying MessagePublishingErrorHandler.

See Section E.6, “Annotation Support” for more information.

All the request-reply endpoints (based on AbstractReplyProducingMessageHandler) can now start transaction and, therefore, make the whole downstream flow transactional.

See Section 8.9.6, “Transaction Support” for more information.

The SmartLifecycleRoleController now provides methods to obtain status of endpoints in roles.

See Section 8.2, “Endpoint Roles” for more information.

POJO methods are now invoked using an InvocableHandlerMethod by default, but can be configured to use SpEL as before.

See Section 3.9, “POJO Method invocation” for more information.

When targeting POJO methods as message handlers, one of the service methods can now be marked with the @Default annotation to provide a fallback mechanism for non-matched conditions.

See Section 8.5.2, “Configuring Service Activator” for more information.

A simple PassThroughTransactionSynchronizationFactory is provided to always store a polled message in the current transaction context. That message is used as a failedMessage property of the MessagingException which wraps a raw exception thrown during transaction completion.

See Section C.3, “Transaction Synchronization” for more information.

The aggregator expression-based ReleaseStrategy now evaluates the expression against the MessageGroup instead of just the collection of Message<?>.

See the section called “Aggregators and Spring Expression Language (SpEL)” for more information.

The ObjectToMapTransformer can now be supplied with a customised JsonObjectMapper.

See the section called “Aggregators and Spring Expression Language (SpEL)” for more information.

The @GlobalChannelInterceptor annotation and <int:channel-interceptor> now support negative patterns (via ! prepending) for component names matching.

See the section called “Global Channel Interceptor Configuration” for more information.

A new OnFailedToAcquireMutexEvent is emitted now via DefaultLeaderEventPublisher by the LockRegistryLeaderInitiator, when candidate is failed to acquire the lock.

See Section 8.3, “Leadership Event Handling” for more information.

2.2.2 Gateway Changes

The gateway now correctly sets the errorChannel header when the gateway method has a void return type and an error channel is provided. Previously, the header was not populated. This had the effect that synchronous downstream flows (running on the calling thread) would send the exception to the configured channel but an exception on an async downstream flow would be sent to the default errorChannel instead.

The RequestReplyExchanger interface now has a throws MessagingException clause to meet all the proposed messages exchange contract.

The request and reply timeouts can now be specified as SpEL expressions.

See Section 8.4, “Messaging Gateways” for more information.

2.2.3 Aggregator Performance Changes

Aggregators now use a SimpleSequenceSizeReleaseStrategy by default, which is more efficient, especially with large groups. Empty groups are now scheduled for removal after empty-group-min-timeout.

See Section 6.4, “Aggregator” for more information.

2.2.4 Splitter Changes

The Splitter component now can handle and split Java Stream and Reactive Streams Publisher objects. If the output channel is a ReactiveStreamsSubscribableChannel, the AbstractMessageSplitter builds a Flux for subsequent iteration instead of a regular Iterator independent of object being split. In addition, AbstractMessageSplitter provides protected obtainSizeIfPossible() methods to allow the determination of the size of the Iterable and Iterator objects if that is possible.

See Section 6.3, “Splitter” for more information.

2.2.5 JMS Changes

Previously, Spring Integration JMS XML configuration used a default bean name connectionFactory for the JMS Connection Factory, allowing the property to be omitted from component definitions. It has now been renamed to jmsConnectionFactory, which is the bean name used by Spring Boot to auto-configure the JMS Connection Factory bean.

If your application is relying on the previous behavior, rename your connectionFactory bean to jmsConnectionFactory, or specifically configure your components to use your bean using its current name.

See Chapter 21, JMS Support for more information.

2.2.6 Mail Changes

Some inconsistencies with rendering IMAP mail content have been resolved.

See the note in the Mail-Receiving Channel Adapter Section for more information.

2.2.7 Feed Changes

Instead of the com.rometools.fetcher.FeedFetcher, which is deprecated in ROME, a new Resource property has been introduced to the FeedEntryMessageSource.

See Chapter 14, Feed Adapter for more information.

2.2.8 File Changes

The new FileHeaders.RELATIVE_PATH Message header has been introduced to represent relative path in the FileReadingMessageSource.

The tail adapter now supports idleEventInterval to emit events when there is no data in the file during that period.

The flush predicates for the FileWritingMessageHandler now have an additional parameter.

The file outbound channel adapter and gateway (FileWritingMessageHandler) now support the REPLACE_IF_MODIFIED FileExistsMode.

They also now support setting file permissions on the newly written file.

A new FileSystemMarkerFilePresentFileListFilter is now available; see Section 15.2.7, “Dealing With Incomplete Data” for more information.

The FileSplitter now provides a firstLineAsHeader option to carry the first line of content as a header in the messages emitted for the remaining lines.

See Chapter 15, File Support for more information.

2.2.9 (S)FTP Changes

The Inbound Channel Adapters now have a property max-fetch-size which is used to limit the number of files fetched during a poll when there are no files currently in the local directory. They also are configured with a FileSystemPersistentAcceptOnceFileListFilter in the local-filter by default.

You can also provide a custom DirectoryScanner implementation to Inbound Channel Adapters via the newly introduced scanner attribute.

The regex and pattern filters can now be configured to always pass directories. This can be useful when using recursion in the outbound gateways.

All the Inbound Channel Adapters (streaming and synchronization-based) now use an appropriate AbstractPersistentAcceptOnceFileListFilter implementation by default to prevent remote files duplicate downloads.

The FTP and SFTP outbound gateways now support the REPLACE_IF_MODIFIED FileExistsMode when fetching remote files.

The (S)FTP streaming inbound channel adapters now add remote file information in a message header.

The FTP and SFTP outbound channel adapters, as well as PUT command of the outbound gateways, now support InputStream as payload, too.

The inbound channel adapters now can build file tree locally using a newly introduced RecursiveDirectoryScanner. See scanner option for injection. Also these adapters can now be switched to the WatchService instead.

The NLST command has been added to the AbstractRemoteFileOutboundGateway to perform only list files names remote command.

The FtpOutboundGateway can now be supplied with workingDirExpression to change the FTP client working directory for the current request message.

The RemoteFileTemplate is supplied now with the invoke(OperationsCallback<F, T> action) to perform several RemoteFileOperations calls in the scope of the same, thread-bounded, Session.

New filters for detecting incomplete remote files are now provided.

The FtpOutboundGateway and SftpOutboundGateway now support an option to remove the remote file after a successful transfer using the GET or MGET commands.

A RotatingServerAdvice is now available to poll multiple servers and/or directories with the inbound channel adapters.

Also inbound adapter localFilenameExpression s can contain the variable #remoteDirectory which contains the remote directory being polled.

See Chapter 16, FTP/FTPS Adapters and Chapter 28, SFTP Adapters for more information.

2.2.10 Integration Properties

Since version 4.3.2 a new spring.integration.readOnly.headers global property has been added to customize the list of headers which should not be copied to a newly created Message by the MessageBuilder.

See Section E.5, “Global Properties” for more information.

2.2.11 Stream Changes

There is a new option on the CharacterStreamReadingMessageSource to allow it to be used to "pipe" stdin and publish an application event when the pipe is closed.

See Section 30.2, “Reading from streams” for more information.

2.2.12 Barrier Changes

The BarrierMessageHandler now supports a discard channel to which late-arriving trigger messages are sent.

See Section 6.8, “Thread Barrier” for more information.

2.2.13 AMQP Changes

The AMQP outbound endpoints now support setting a delay expression for when using the RabbitMQ Delayed Message Exchange plugin.

The inbound endpoints now support the Spring AMQP DirectMessageListenerContainer.

Pollable AMQP-backed channels now block the poller thread for the poller’s configured receiveTimeout (default 1 second).

Headers, such as contentType that are added to message properties by the message converter are now used in the final message; previously, it depended on the converter type as to which headers/message properties appeared in the final message. To override headers set by the converter, set the headersMappedLast property to true.

See Chapter 12, AMQP Support for more information.

2.2.14 HTTP Changes

The DefaultHttpHeaderMapper.userDefinedHeaderPrefix property is now an empty string by default instead of X-.

See Section 18.8, “HTTP Header Mappings” for more information.

2.2.15 MQTT Changes

Inbound messages are now mapped with headers RECEIVED_TOPIC, RECEIVED_QOS and RECEIVED_RETAINED to avoid inadvertent propagation to outbound messages when an application is relaying messages.

The outbound channel adapter now supports expressions for the topic, qos and retained properties; the defaults remain the same.

See Chapter 24, MQTT Support for more information.

2.2.16 STOMP Changes

The STOMP module has been changed to use ReactorNettyTcpStompClient, based on the Project Reactor 3.1 and reactor-netty extension. The Reactor2TcpStompSessionManager has been renamed to the ReactorNettyTcpStompSessionManager according to the ReactorNettyTcpStompClient foundation.

See Chapter 29, STOMP Support for more information.

2.2.17 Web Services Changes

  • The WebServiceOutboundGateway s can now be supplied with an externally configured WebServiceTemplate instances.
  • The DefaultSoapHeaderMapper can now map a javax.xml.transform.Source user-defined header to a SOAP header element.
  • Simple WebService Inbound and Outbound gateways can now deal with the complete WebServiceMessage as a payload, allowing the manipulation of MTOM attachments.

See Chapter 36, Web Services Support for more information.

2.2.18 Redis Changes

The RedisStoreWritingMessageHandler is supplied now with additional String-based setters for SpEL expressions - for convenience with Java configuration. The zsetIncrementExpression can now be configured on the RedisStoreWritingMessageHandler, as well. In addition this property has been changed from true to false since INCR option on ZADD Redis command is optional.

The RedisInboundChannelAdapter can now be supplied with an Executor for executing Redis listener invokers. In addition the received messages now contains a RedisHeaders.MESSAGE_SOURCE header to indicate the source of the message - topic or pattern.

See Chapter 25, Redis Support for more information.

2.2.19 TCP Changes

A new ThreadAffinityClientConnectionFactory is provided that binds TCP connections to threads.

You can now configure the TCP connection factories to support PushbackInputStream s, allowing deserializers to "unread" (push back) bytes after "reading ahead".

A ByteArrayElasticRawDeserializer has been added without maxMessageSize control and buffer incoming data as needed.

See Chapter 32, TCP and UDP Support for more information.

2.2.20 Gemfire Changes

The GemfireMetadataStore now implements ListenableMetadataStore, allowing users to listen to cache events by providing MetadataStoreListener instances to the store.

See Chapter 17, GemFire Support for more information.

2.2.21 Jdbc Changes

The JdbcMessageChannelStore now provides setter for the ChannelMessageStorePreparedStatementSetter allowing users to customize a message insertion in the store.

The ExpressionEvaluatingSqlParameterSourceFactory now provides setter for the sqlParameterTypes allowing users to customize sql types of the parameters.

See Chapter 19, JDBC Support for more information.

2.2.22 Metrics Changes

Micrometer application monitoring is now supported (since version 5.0.2). See Section 10.1.2, “Micrometer Integration” for more information.

[Important]Important

Changes were made to the Micrometer Meters in version 5.0.3 to make them more suitable for use in dimensional systems. Further changes were made in 5.0.4; if using Micrometer, a minimum of version 5.0.4 is recommended.

2.3 TCP Support

When using SSL, host verification can be configured, to prevent man-in-the-middle attacks with a trusted certificate. See Section 32.10.3, “Host Verification” for more information.

In addition the key and trust store types can now be configured on the DefaultTcpSSLContextSupport.

2.3.1 @EndpointId Annotations

Introduced in version 5.0.4, this annotation provides control over bean naming when using Java configuration. See Section 3.4.8, “Endpoint Bean Names” for more information.

2.3.2 Integration Flows: Generated bean names

Starting with version 5.0.5, generated bean names for the components in an IntegrationFlow include the flow bean name, followed by a dot, as a prefix.

See Section 9.15, “Working With Message Flows” for more information.