[[migration-4.0-4.1]]
= Changes between 4.0 and 4.1

See the https://github.com/spring-projects/spring-integration/wiki/Spring-Integration-4.0-to-4.1-Migration-Guide[Migration Guide] for important changes that might affect your applications.
You can find migration guides for all versions back to 2.1 on the https://github.com/spring-projects/spring-integration/wiki[wiki].

[[new-components]]
== New Components

Version 4.1 added a number of new components.

[[x4.1-promise-gateway]]
=== Promise<?> Gateway

The messaging gateway methods now support a Reactor `Promise` return type.
See xref:jms.adoc#jms-async-gateway[Asynchronous Gateway].

[[x4.1-web-socket-adapters]]
=== WebSocket support

The `WebSocket` module is now available.
It is fully based on the Spring WebSocket and Spring Messaging modules and provides an `<inbound-channel-adapter>` and an `<outbound-channel-adapter>`.
See xref:web-sockets.adoc[WebSockets Support] for more information.

[[x4.1-scatter-gather]]
=== Scatter-Gather Enterprise Integration Pattern

We implemented the scatter-gather enterprise integration pattern.
See xref:scatter-gather.adoc[Scatter-Gather] for more information.

[[x4.1-Routing-Slip]]
=== Routing Slip Pattern

We added the routing slip EIP pattern implementation.
See xref:router/routing-slip.adoc[Routing Slip] for more information.

[[x4.1-idempotent-receiver]]
=== Idempotent Receiver Pattern

We added the idempotent receiver enterprise integration pattern implementation by adding the `<idempotent-receiver>` component in XML or the `IdempotentReceiverInterceptor` and `IdempotentReceiver` annotations for Java configuration.
See xref:handler-advice/idempotent-receiver.adoc[Idempotent Receiver Enterprise Integration Pattern] and the https://docs.spring.io/spring-integration/api/index.html[Javadoc] for more information.

[[x4.1-BoonJsonObjectMapper]]
=== Boon `JsonObjectMapper`

We added the Boon `JsonObjectMapper` for the JSON transformers.
See xref:transformer.adoc[Transformer] for more information.

[[x4.1-redis-queue-gateways]]
=== Redis Queue Gateways

We added the `<redis-queue-inbound-gateway>` and `<redis-queue-outbound-gateway>` components.
See xref:redis.adoc#redis-queue-inbound-gateway[Redis Queue Inbound Gateway] and xref:redis.adoc#redis-queue-outbound-gateway[Redis Queue Outbound Gateway].

[[x4.1-PollSkipAdvice]]
=== `PollSkipAdvice`

We added the `PollSkipAdvice`, which you can use within the `<advice-chain>` of the `<poller>` to determine if the current poll should be suppressed (skipped) by some condition that you implement with `PollSkipStrategy`.
See xref:polling-consumer.adoc#polling-consumer[Poller] for more information.

[[x4.1-general]]
== General Changes

This section describes general changes from version 4.0 to version 4.1.

[[x4.1-amqp-inbound-missing-queues]]
=== AMQP Inbound Endpoints, Channel

Elements that use a message listener container (inbound endpoints and channel) now support the `missing-queues-fatal` attribute.
See xref:amqp.adoc[AMQP Support] for more information.

[[x4.1-amqp-outbound-lazy-connect]]
=== AMQP Outbound Endpoints

The AMQP outbound endpoints support a new property called `lazy-connect` (default: `true`).
When `true`, the connection to the broker is not established until the first message arrives (assuming there are no inbound endpoints, which always try to establish the connection during startup).
When set to `false`, an attempt to establish the connection is made during application startup.
See xref:amqp.adoc[AMQP Support] for more information.

[[x4.1-sms-copy-on-get]]
=== SimpleMessageStore

The `SimpleMessageStore` no longer makes a copy of the group when calling `getMessageGroup()`.
See xref:message-store.adoc#sms-caution[[WARNING]] for more information.

[[x4.1-ws-encode-uri]]
=== Web Service Outbound Gateway: `encode-uri`

The `<ws:outbound-gateway/>` now provides an `encode-uri` attribute to allow disabling the encoding of the URI object before sending the request.

[[x4.1-http-status-code]]
=== Http Inbound Channel Adapter and Status Code

The `<http:inbound-channel-adapter>` can now be configured with a `status-code-expression` to override the default `200 OK` status.
See xref:http/namespace.adoc[HTTP Namespace Support] for more information.

[[x4.1-mqtt]]
=== MQTT Adapter Changes

You can now configure the MQTT channel adapters to connect to multiple servers -- for example, to support High Availability (HA).
See xref:mqtt.adoc[MQTT Support] for more information.

The MQTT message-driven channel adapter now supports specifying the QoS setting for each subscription.
See xref:mqtt.adoc#mqtt-inbound[Inbound (Message-driven) Channel Adapter] for more information.

The MQTT outbound channel adapter now supports asynchronous sends, avoiding blocking until delivery is confirmed.
See xref:mqtt.adoc#mqtt-outbound[Outbound Channel Adapter] for more information.

It is now possible to programmatically subscribe to and unsubscribe from topics at runtime.
See xref:mqtt.adoc#mqtt-inbound[Inbound (Message-driven) Channel Adapter] for more information.

[[x4.1-sftp]]
=== FTP and SFTP Adapter Changes

The FTP and SFTP outbound channel adapters now support appending to remote files and taking specific actions when a remote file already exists.
The remote file templates now also supports this, as well as `rmdir()` and `exists()`.
In addition, the remote file templates provide access to the underlying client object, enabling access to low-level APIs.

See xref:ftp.adoc[FTP/FTPS Adapters] and xref:sftp.adoc[SFTP Adapters] for more information.

[[x4.1-splitter-iterator]]
=== Splitter and Iterator

`Splitter` components now support an `Iterator` as the result object for producing output messages.
See xref:splitter.adoc[Splitter] for more information.

[[x4.1-aggregator]]
=== Aggregator

`Aggregator` instancess now support a new attribute `expire-groups-upon-timeout`.
See xref:overview.adoc#overview-endpoints-aggregator[Aggregator] for more information.

[[x4.1-content-enricher-improvement]]
=== Content Enricher Improvements

We added a `null-result-expression` attribute, which is evaluated and returned if `<enricher>` returns `null`.
You can add it in `<header>` and `<property>`.
See xref:content-enrichment.adoc[Content Enricher] for more information.

We added an `error-channel` attribute, which is used to handle an error flow if an `Exception` occurs downstream of the `request-channel`.
This lets you return an alternative object to use for enrichment.
See xref:content-enrichment.adoc[Content Enricher] for more information.

[[x4.1-header-channel-registry]]
=== Header Channel Registry

The `<header-enricher/>` element's `<header-channels-to-string/>` child element can now override the header channel registry's default time for retaining channel mappings.
See xref:content-enrichment.adoc#header-channel-registry[Header Channel Registry] for more information.

[[x4.1-orderly-shutdown]]
=== Orderly Shutdown

We made improvements to the orderly shutdown algorithm.
See xref:shutdown.adoc[Orderly Shutdown] for more information.

[[x4.1-recipientListRouter]]
=== Management for `RecipientListRouter`

The `RecipientListRouter` now provides several management operations to configure recipients at runtime.
With that, you can now configure the `<recipient-list-router>` without any `<recipient>` from the start.
See xref:router/implementations.adoc#recipient-list-router-management[`RecipientListRouterManagement`] for more information.

[[x4.1-AbstractHeaderMapper-changes]]
=== AbstractHeaderMapper: NON_STANDARD_HEADERS token

The `AbstractHeaderMapper` implementation now provides the additional `NON_STANDARD_HEADERS` token to map any user-defined headers, which are not mapped by default.
See xref:amqp/message-headers.adoc[AMQP Message Headers] for more information.

[[x4.1-amqp-channels]]
=== AMQP Channels: `template-channel-transacted`

We introduced the `template-channel-transacted` attribute for AMQP `MessageChannel` instances.
See xref:amqp/channels.adoc[AMQP-backed Message Channels] for more information.

[[x4.1-syslog]]
=== Syslog Adapter

The default syslog message converter now has an option to retain the original message in the payload while still setting the headers.
See xref:syslog.adoc#syslog-inbound-adapter[Syslog Inbound Channel Adapter] for more information.

[[x4.1-async-gateway]]
=== Asynchronous Gateway

In addition to the `Promise` return type xref:changes-4.0-4.1.adoc#x4.1-promise-gateway[mentioned earlier], gateway methods may now return a `ListenableFuture`, introduced in Spring Framework 4.0.
You can also disable asynchronous processing in the gateway, letting a downstream flow directly return a `Future`.
See xref:jms.adoc#jms-async-gateway[Asynchronous Gateway].

[[x4.1-aggregator-advice-chain]]
=== Aggregator Advice Chain

`Aggregator` and `Resequencer` now support `<expire-advice-chain/>` and `<expire-transactional/>` child elements to advise the `forceComplete` operation.
See xref:aggregator.adoc#aggregator-xml[Configuring an Aggregator with XML] for more information.

[[x4.1-script-outbound-channel-adapter]]
=== Outbound Channel Adapter and Scripts

The `<int:outbound-channel-adapter/>` now supports the `<script/>` child element.
The underlying script must have a `void` return type or return `null`.
See xref:groovy.adoc[Groovy support] and xref:scripting.adoc[Scripting Support].

[[x4.1-reseq]]
=== Resequencer Changes

When a message group in a resequencer times out (using `group-timeout` or a `MessageGroupStoreReaper`), late arriving messages are now, by default, discarded immediately.
See xref:resequencer.adoc[Resequencer].

[[x4.1-Optional-Parameter]]
=== Optional POJO method parameter

Spring Integration now consistently handles the Java 8's `Optional` type.
See xref:service-activator.adoc#service-activator-namespace[Configuring Service Activator].

[[x4.1-queue-channel-queue.typ]]
=== `QueueChannel` backed Queue type

The `QueueChannel` backed `Queue type` has been changed from `BlockingQueue` to the more generic `Queue`.
This change allows the use of any external `Queue` implementation (for example, Reactor's `PersistentQueue`).
See xref:channel/configuration.adoc#channel-configuration-queuechannel[`QueueChannel` Configuration].

[[x4.1-channel-interceptor]]
=== `ChannelInterceptor` Changes

The `ChannelInterceptor` now supports additional `afterSendCompletion()` and `afterReceiveCompletion()` methods.
See xref:channel/interceptors.adoc[Channel Interceptors].

[[x4.1-mail-peek]]
=== IMAP PEEK

Since version 4.1.1 there is a change of behavior if you explicitly set the `mail.[protocol].peek` JavaMail property to `false` (where `[protocol]` is `imap` or `imaps`).
See xref:changes-4.0-4.1.adoc#x4.1-mail-peek[[IMPORTANT]].
