[[migration-4.2-4.3]]
= Changes between 4.2 and 4.3

See the https://github.com/spring-projects/spring-integration/wiki/Spring-Integration-4.2-to-4.3-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].

[[x4.3-new-components]]
== New Components

Version 4.3 added a number of new components.

[[amqp-async-outbound-gateway]]
=== AMQP Async Outbound Gateway

See xref:amqp.adoc#amqp-async-outbound-gateway[Asynchronous Outbound Gateway].

[[messagegroupfactory]]
=== `MessageGroupFactory`

We introduced the `MessageGroupFactory` strategy to allow control over `MessageGroup` instances in `MessageGroupStore` logic.
We added `SimpleMessageGroupFactory` implementation for the `SimpleMessageGroup`, with the `GroupType.HASH_SET` as the default
factory for the standard `MessageGroupStore` implementations.
See xref:message-store.adoc[Message Store] for more information.

[[persistentmessagegroup]]
=== `PersistentMessageGroup`

We added the `PersistentMessageGroup` (lazy-load proxy) implementation for persistent `MessageGroupStore` instances,
which return this instance for the `getMessageGroup()` when their `lazyLoadMessageGroups` is `true` (the default).
See xref:message-store.adoc[Message Store] for more information.

[[ftp-and-sftp-streaming-inbound-channel-adapters]]
=== FTP and SFTP Streaming Inbound Channel Adapters

We added inbound channel adapters that return an `InputStream` for each file, letting you retrieve remote files without writing them to the local file system.
See xref:ftp/streaming.adoc[FTP Streaming Inbound Channel Adapter] and xref:sftp/streaming.adoc[SFTP Streaming Inbound Channel Adapter] for more information.

[[streamtransformer]]
=== `StreamTransformer`

We added `StreamTransformer` to transform an `InputStream` payload to either a `byte[]` or a `String`.
See xref:transformer.adoc#stream-transformer[Stream Transformer] for more information.

[[integration-graph]]
=== Integration Graph

We added `IntegrationGraphServer`, together with the `IntegrationGraphController` REST service, to expose the runtime model of a Spring Integration application as a graph.
See xref:graph.adoc#integration-graph[Integration Graph] for more information.

[[jdbc-lock-registry]]
=== JDBC Lock Registry

We added `JdbcLockRegistry` for distributed locks shared through a database table.
See xref:jdbc.adoc#jdbc-lock-registry[JDBC Lock Registry] for more information.

[[leaderinitiator-for-lockregistry]]
=== `LeaderInitiator` for `LockRegistry`

We added `LeaderInitiator` implementation based on the `LockRegistry` strategy.
See xref:endpoint.adoc#leadership-event-handling[Leadership Event Handling] for more information.

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

This section describes general changes that version 4.3 brought to Spring Integration.

[[core-changes]]
=== Core Changes

This section describes general changes to the core of Spring Integration.

[[outbound-gateway-within-a-chain]]
==== Outbound Gateway within a Chain

Previously, you could specify a `reply-channel` on an outbound gateway within a chain.
It was completely ignored.
The gateway's reply goes to the next chain element or, if the gateway is the last element, to the chain's output channel.
This condition is now detected and disallowed.
If you have such a configuration, remove the `reply-channel`.

[[asynchronous-service-activator]]
==== Asynchronous Service Activator

We added an option to make the service activator be synchronous.
See xref:service-activator.adoc#async-service-activator[Asynchronous Service Activator] for more information.

[[messaging-annotation-support-changes]]
==== Messaging Annotation Support changes

The messaging annotation support does not require a `@MessageEndpoint` (or any other `@Component`) annotation declaration on the class level.
To restore the previous behavior, set the `spring.integration.messagingAnnotations.require.componentAnnotation` of
`spring.integration.properties` to `true`.
See xref:configuration/global-properties.adoc[Global Properties] and xref:configuration/annotations.adoc[Annotation Support] for more information.

[[mail-changes]]
=== Mail Changes

This section describes general changes to the Spring Integration Mail functionality.

[[customizable-user-flag]]
==== Customizable User Flag

The customizable `userFlag` (added in 4.2.2 to provide customization of the flag used to denote that the mail has been
seen) is now available in the XML namespace.
See xref:mail.adoc#imap-seen[Marking IMAP Messages When `Recent` Is Not Supported] for more information.

[[mail-message-mapping]]
==== Mail Message Mapping

You can now map inbound mail messages with the `MessageHeaders` containing the mail headers and the payload containing the email content.
Previously, the payload was always the raw `MimeMessage`.
See xref:mail.adoc#mail-mapping[Inbound Mail Message Mapping] for more information.

[[jms-changes]]
=== JMS Changes

This section describes general changes to the Spring Integration JMS functionality.

[[header-mapper]]
==== Header Mapper

The `DefaultJmsHeaderMapper` now maps the standard `correlationId` header as a message property by invoking its `toString()` method.
See xref:changes-3.0-4.0.adoc#x4.0-jms-header-mapping[Mapping Message Headers to and from JMS Message] for more information.

[[asynchronous-gateway]]
==== Asynchronous Gateway

The JMS outbound gateway now has an `async` property.
See xref:jms.adoc#jms-async-gateway[Async Gateway] for more information.

[[aggregator-changes]]
=== Aggregator Changes

There is a change in behavior when a POJO aggregator releases a collection of `Message<?>` objects.
This is rare, but, if your application does that, you need to make a small change to your POJO.
See this xref:aggregator.adoc#agg-message-collection[IMPORTANT: The `SimpleMessageGroup.getMessages()` method returns an `unmodifiableCollection`.] note for more information.

[[tcp/udp-changes]]
=== TCP/UDP Changes

This section describes general changes to the Spring Integration TCP/UDP functionality.

[[events]]
==== Events

A new `TcpConnectionServerListeningEvent` is emitted when a server connection factory is started.
See xref:changes-4.1-4.2.adoc#x4.2-tcp-events[TCP Connection Events] for more information.

You can now use the `destination-expression` and `socket-expression` attributes on `<int-ip:udp-outbound-channel-adapter>`.
See xref:ip/udp-adapters.adoc[UDP Adapters] for more information.

[[stream-deserializers]]
==== Stream Deserializers

The various deserializers that cannot allocate the final buffer until the whole message has been assembled now support pooling the raw buffer into which the data is received rather than creating and discarding a buffer for each message.
See xref:ip/tcp-connection-factories.adoc[TCP Connection Factories] for more information.

[[tcp-message-mapper]]
==== TCP Message Mapper

The message mapper now, optionally, sets a configured content type header.
See xref:ip/msg-headers.adoc[IP Message Headers] for more information.

[[file-changes]]
=== File Changes

This section describes general changes to the Spring Integration File functionality.

[[destination-directory-creation]]
==== Destination Directory Creation

The generated file name for the `FileWritingMessageHandler` can represent a sub-path to save the desired directory structure for a file in the target directory.
See xref:file/writing.adoc#file-writing-file-names[Generating File Names] for more information.

The `FileReadingMessageSource` now hides the `WatchService` directory scanning logic in the inner class.
We added the `use-watch-service` and `watch-events` options to enable this behavior.
We deprecated the top-level `WatchServiceDirectoryScanner` because of inconsistency around the API.
See xref:file.adoc#watch-service-directory-scanner[`WatchServiceDirectoryScanner`] for more information.

[[buffer-size]]
==== Buffer Size

When writing files, you can now specify the buffer size.

[[appending-and-flushing]]
==== Appending and Flushing

You can now avoid flushing files when appending and use a number of strategies to flush the data during idle periods.
See xref:file/writing.adoc#file-flushing[Flushing Files When Using `APPEND_NO_FLUSH`] for more information.

[[preserving-timestamps]]
==== Preserving Timestamps

You can now configure the outbound channel adapter to set the destination file's `lastmodified` timestamp.
See xref:file/writing.adoc#file-timestamps[File Timestamps] for more information.

[[splitter-changes]]
==== Splitter Changes

The `FileSplitter` now automatically closes an FTP or SFTP session when the file is completely read.
This applies when the outbound gateway returns an `InputStream` or when you use the new FTP or SFTP streaming channel adapters.
We also introduced a new `markers-json` option to convert `FileSplitter.FileMarker` to JSON `String` for relaxed downstream network interaction.
See xref:file/splitter.adoc[File Splitter] for more information.

[[file-filters]]
==== File Filters

We added `ChainFileListFilter` as an alternative to `CompositeFileListFilter`.
See xref:file/reading.adoc[Reading Files] for more information.

[[amqp-changes]]
=== AMQP Changes

This section describes general changes to the Spring Integration AMQP functionality.

[[content-type-message-converter]]
==== Content Type Message Converter

The outbound endpoints now support a `RabbitTemplate` configured with a `ContentTypeDelegatingMessageConverter` such
that you can choose the converter based on the message content type.
See xref:amqp/content-type-conversion-outbound.adoc[Outbound Message Conversion] for more information.

[[headers-for-delayed-message-handling]]
==== Headers for Delayed Message Handling

Spring AMQP 1.6 adds support for https://www.rabbitmq.com/blog/2015/04/16/scheduling-messages-with-rabbitmq/[delayed message exchanges].
Header mapping now supports the headers (`amqp_delay` and `amqp_receivedDelay`) used by this feature.

[[amqp-backed-channels]]
==== AMQP-Backed Channels

AMQP-backed channels now support message mapping.
See xref:amqp/channels.adoc[AMQP-backed Message Channels] for more information.

[[redis-changes]]
=== Redis Changes

This section describes general changes to the Spring Integration Redis functionality.

[[list-push/pop-direction]]
==== List Push/Pop Direction

Previously, the queue channel adapters always used the Redis list in a fixed direction, pushing to the left end and reading from the right end.
You can now configure the reading and writing direction with the `rightPop` and `leftPush` options for the
`RedisQueueMessageDrivenEndpoint` and `RedisQueueOutboundChannelAdapter`, respectively.
See xref:redis.adoc#redis-queue-inbound-channel-adapter[Redis Queue Inbound Channel Adapter] and xref:redis.adoc#redis-queue-outbound-channel-adapter[Redis Queue Outbound Channel Adapter] for more information.

[[queue-inbound-gateway-default-serializer]]
==== Queue Inbound Gateway Default Serializer

The default serializer in the inbound gateway has been changed to a `JdkSerializationRedisSerializer` for compatibility with the outbound gateway.
See xref:redis.adoc#redis-queue-inbound-gateway[Redis Queue Inbound Gateway] for more information.

[[http-changes]]
=== HTTP Changes

Previously, with requests that had a body (such as `POST`) that had no `content-type` header, the body was ignored.
With this release, the content type of such requests is considered to be `application/octet-stream` as recommended
by RFC 2616.
See xref:http/inbound.adoc[Http Inbound Components] for more information.

`uriVariablesExpression` now uses a `SimpleEvaluationContext` by default (since 4.3.15).
See xref:http/namespace.adoc#mapping-uri-variables[Mapping URI Variables] for more information.

[[sftp-changes]]
=== SFTP Changes

This section describes general changes to the Spring Integration SFTP functionality.

[[factory-bean]]
==== Factory Bean

We added a new factory bean to simplify the configuration of Jsch proxies for SFTP.
See `JschProxyFactoryBean` for more information.

[[chmod-changes]]
==== `chmod` Changes

The SFTP outbound gateway (for `put` and `mput` commands) and the SFTP outbound channel adapter now support the `chmod` attribute to change the remote file permissions after uploading.
See `xref:sftp/outbound.adoc[SFTP Outbound Channel Adapter]` and `xref:sftp/outbound-gateway.adoc[SFTP Outbound Gateway]` for more information.

[[ftp-changes]]
=== FTP Changes

This section describes general changes to the Spring Integration FTP functionality.

[[session-changes]]
==== Session Changes

The `FtpSession` now supports `null` for the `list()` and `listNames()` methods, since underlying FTP Client can use it.
With that, you can now configure the `FtpOutboundGateway` without the `remoteDirectory` expression.
You can also configure the `<int-ftp:inbound-channel-adapter>` without `remote-directory` or `remote-directory-expression`.
See xref:ftp.adoc[FTP/FTPS Adapters] for more information.

[[router-changes]]
=== Router Changes

The `ErrorMessageExceptionTypeRouter` now supports the `Exception` superclass mappings to avoid duplication for the same channel in case of multiple inheritors.
For this purpose, the `ErrorMessageExceptionTypeRouter` loads mapping classes during initialization to fail-fast for a `ClassNotFoundException`.

See xref:router.adoc[Routers] for more information.

[[header-mapping]]
=== Header Mapping

This section describes the changes to header mapping between version 4.2 and 4.3.

[[general]]
==== General

AMQP, WS, and XMPP header mappings (such as `request-header-mapping` and `reply-header-mapping`) now support negated patterns.
See xref:amqp/message-headers.adoc[AMQP Message Headers], xref:ws.adoc#ws-message-headers[WS Message Headers], and xref:xmpp.adoc#xmpp-message-headers[XMPP Message Headers] for more information.

[[amqp-header-mapping]]
==== AMQP Header Mapping

Previously, only standard AMQP headers were mapped by default.
You had to explicitly enable mapping of user-defined headers.
With this release, all headers are mapped by default.
In addition, the inbound `amqp_deliveryMode` header is no longer mapped by default.
See xref:amqp/message-headers.adoc[AMQP Message Headers] for more information.

[[groovy-scripts]]
=== Groovy Scripts

You can now configure groovy scripts with the `compile-static` hint or any other `CompilerConfiguration` options.
See xref:groovy.adoc#groovy-config[Groovy Configuration] for more information.

[[inboundchanneladapter-changes]]
=== `@InboundChannelAdapter` Changes

The `@InboundChannelAdapter` now has an alias `channel` attribute for the regular `value`.
In addition, the target `SourcePollingChannelAdapter` components can now resolve the target `outputChannel` bean from its provided name (`outputChannelName` options) in a late-binding manner.
See xref:configuration/annotations.adoc[Annotation Support] for more information.

[[xmpp-changes]]
=== XMPP Changes

The XMPP channel adapters now support the XMPP Extensions (XEP).
See xref:xmpp.adoc#xmpp-extensions[XMPP Extensions] for more information.

[[wiretap-late-binding]]
=== WireTap Late Binding

The `WireTap` `ChannelInterceptor` now can accept a `channelName` that is resolved to the target `MessageChannel`
later, during the first active interceptor operation.
See xref:channel/configuration.adoc#channel-wiretap[Wire Tap] for more information.

[[channelmessagestorequeryprovider-changes]]
=== `ChannelMessageStoreQueryProvider` Changes

The `ChannelMessageStoreQueryProvider` now supports H2 databases.
See xref:jdbc/message-store.adoc#jdbc-message-store-channels[Backing Message Channels] for more information.

[[websocket-changes]]
=== WebSocket Changes

The `ServerWebSocketContainer` now exposes an `allowedOrigins` option, and `SockJsServiceOptions` exposes a `suppressCors` option.
See xref:web-sockets.adoc[WebSockets Support] for more information.
