[[migration-5.0-5.1]]
= Changes between 5.0 and 5.1

[[x5.1-new-components]]
== New Components

The following components are new in 5.1:

* xref:changes-5.0-5.1.adoc#x5.1-AmqpDedicatedChannelAdvice[`AmqpDedicatedChannelAdvice`]

[[x5.1-AmqpDedicatedChannelAdvice]]
=== `AmqpDedicatedChannelAdvice`

See xref:amqp/strict-ordering.adoc[Strict Message Ordering].

[[x5.1-Functions]]
=== Improved Function Support

The `java.util.function` interfaces now have improved integration support in the Framework components.
Also Kotlin lambdas now can be used for handler and source methods.

See xref:functions-support.adoc[`java.util.function` Interfaces Support].

[[x5.1-LongRunningTest]]
=== `@LongRunningTest`

A JUnit 5 `@LongRunningTest` conditional annotation is provided to check the environment or system properties for the `RUN_LONG_INTEGRATION_TESTS` entry with the value of `true` to determine if test should be run or skipped.

See xref:testing.adoc#test-junit-rules[JUnit Rules and Conditions].

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

The following changes have been made in version 5.1:

* xref:changes-5.0-5.1.adoc#x5.1-java-dsl[Java DSL]
* xref:changes-5.0-5.1.adoc#x5.1-dispatcher-exceptions[Dispatcher Exceptions]
* xref:changes-5.0-5.1.adoc#x5.1-global-channel-interceptors[Global Channel Interceptors]
* xref:changes-5.0-5.1.adoc#x5.1-object-to-json-transformer[`ObjectToJsonTransformer`]
* xref:changes-5.0-5.1.adoc#x5.1-integration-flows-generated-bean-names[Integration Flows: Generated Bean Names]
* xref:changes-5.0-5.1.adoc#x5.1-aggregator[Aggregator Changes]
* xref:changes-5.0-5.1.adoc#x5.1-publisher[@Publisher annotation changes]
* xref:changes-5.0-5.1.adoc#x51.-integration-graph[Integration Graph Customization]
* xref:changes-5.0-5.1.adoc#x51.-global-properties[Integration Global Properties]
* xref:changes-5.0-5.1.adoc#x51.-poller-annotation[The `receiveTimeout` for `@Poller`]

[[x5.1-java-dsl]]
=== Java DSL

The `IntegrationFlowContext` is now an interface and `IntegrationFlowRegistration` is an inner interface of `IntegrationFlowContext`.

A new `logAndReply()` operator has been introduced for convenience when you wish to log at the end of a flow for request-reply configurations.
This avoids confusion with `log()` which is treated as a one-way end flow component.

A generated bean name for any `NamedComponent` within an integration flow is now based on the component type for better readability from visual tools, logs analyzers and metrics collectors.

The `GenericHandler.handle()` now excepts a `MessageHeaders` type for the second argument.

[[x5.1-dispatcher-exceptions]]
=== Dispatcher Exceptions

Exceptions caught and re-thrown by `AbstractDispatcher` are now more consistent:

* A `MessagingException` of any kind that has a `failedMessage` property is re-thrown unchanged.
* All other exceptions are wrapped in a `MessageDeliveryException` with the `failedMessage` property set.

Previously:

* A `MessagingException` of any kind that has a `failedMessage` property was re-thrown unchanged
* A `MessagingException` that had no `failedMessage` property was wrapped in a `MessagingException` with the `failedMessage` property set.
* Other `RuntimeException` instances were re-thrown unchanged.
* Checked exceptions were wrapped in a `MessageDeliveryException` with the `failedMessage` property set.

[[x5.1-global-channel-interceptors]]
=== Global Channel Interceptors

Global channel interceptors now apply to dynamically registered channels, such as through the `IntegrationFlowContext` when using the Java DSL or beans that are initialized using `beanFactory.initializeBean()`.
Previously, when beans were created after the application context was refreshed, interceptors were not applied.

[[x5.1-channel-interceptors]]
=== Channel Interceptors

`ChannelInterceptor.postReceive()` is no longer called when no message is received; it is no longer necessary to check for a `null` `Message<?>`.
Previously, the method was called.
If you have an interceptor that relies on the previous behavior, implement `afterReceiveCompleted()` instead, since that method is invoked, regardless of whether a message is received or not.
Furthermore, the `PolledAmqpChannel` and `PolledJmsChannel` previously did not invoke `afterReceiveCompleted()` with `null`; they now do.

[[x5.1-object-to-json-transformer]]
=== `ObjectToJsonTransformer`

A new `ResultType.BYTES` mode is introduced for the `ObjectToJsonTransformer`.

See xref:transformer.adoc#json-transformers[JSON Transformers] for more information.

[[x5.1-integration-flows-generated-bean-names]]
=== 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.
For example, if a flow bean were named `flowBean`, a generated bean might be named `flowBean.generatedBean`.

See xref:dsl/java-flows.adoc[Working With Message Flows] for more information.

[[x5.1-aggregator]]
=== Aggregator Changes

If the `groupTimeout` is evaluated to a negative value, an aggregator now expires the group immediately.
Only `null` is considered as a signal to do nothing for the current message.

A new `popSequence` property has been introduced to allow (by default) to call a `MessageBuilder.popSequenceDetails()` for the output message.
Also an `AbstractAggregatingMessageGroupProcessor` returns now an `AbstractIntegrationMessageBuilder` instead of the whole `Message` for optimization.

See xref:overview.adoc#overview-endpoints-aggregator[Aggregator] for more information.

[[x5.1-publisher]]
=== @Publisher annotation changes

Starting with version 5.1, you must explicitly turn on the `@Publisher` AOP functionality by using `@EnablePublisher` or by using the `<int:enable-publisher>` child element on `<int:annotation-config>`.
Also the `proxy-target-class` and `order` attributes have been added for tuning the `ProxyFactory` configuration.

See xref:message-publishing.adoc#publisher-annotation[Annotation-driven Configuration with the `@Publisher` Annotation] for more information.

[[x5.1-files]]
== Files Changes

If you are using `FileExistsMode.APPEND` or `FileExistsMode.APPEND_NO_FLUSH` you can provide a `newFileCallback` that will be called when creating a new file.
This callback receives the newly created file and the message that triggered the callback.
This could be used to write a CSV header, for an example.

The `FileReadingMessageSource` now doesn't check and create a directory until its `start()` is called.
So, if an Inbound Channel Adapter for the `FileReadingMessageSource` has `autoStartup = false`, there are no failures against the file system during application start up.

See xref:file.adoc[File Support] for more information.

[[x5.1-amqp]]
== AMQP Changes

We have made `ID` and `Timestamp` header mapping changes in the `DefaultAmqpHeaderMapper`.
See the note near the bottom of xref:amqp/message-headers.adoc[AMQP Message Headers] for more information.

The `contentType` header is now correctly mapped as an entry in the general headers map.
See xref:amqp/message-headers.adoc#amqp-content-type[contentType Header] for more information.

Starting with version 5.1.3, if a message conversion exception occurs when using manual acknowledgments, and an error channel is defined, the payload is a `ManualAckListenerExecutionFailedException` with additional `channel` and `deliveryTag` properties.
This enables the error flow to ack/nack the original message.
See xref:amqp/conversion-inbound.adoc[Inbound Message Conversion] for more information.

[[x5.1-jdbc]]
== JDBC Changes

A confusing `max-rows-per-poll` property on the JDBC Inbound Channel Adapter and JDBC Outbound Gateway has been deprecated in favor of the newly introduced `max-rows` property.

The `JdbcMessageHandler` supports now a `batchUpdate` functionality when the payload of the request message is an instance of an `Iterable` type.

The indexes for the `INT_CHANNEL_MESSAGE` table (for the `JdbcChannelMessageStore`) have been optimized.
If you have large message groups in such a store, you may wish to alter the indexes.

See xref:jdbc.adoc[JDBC Support] for more information.

[[x5.1-ftp-sftp]]
== FTP and SFTP Changes

A `RotatingServerAdvice` is now available to poll multiple servers and directories with the inbound channel adapters.
See xref:ftp/rotating-server-advice.adoc[Inbound Channel Adapters: Polling Multiple Servers and Directories] and xref:sftp/rotating-server-advice.adoc[Inbound Channel Adapters: Polling Multiple Servers and Directories] for more information.

Also, inbound adapter `localFilenameExpression` instances can contain the `#remoteDirectory` variable, which contains the remote directory being polled.
The generic type of the comparators (used to sort the fetched file list for the streaming adapters) has changed from `Comparator<AbstractFileInfo<F>>` to `Comparator<F>`.
See xref:ftp/streaming.adoc[FTP Streaming Inbound Channel Adapter] and xref:sftp/streaming.adoc[SFTP Streaming Inbound Channel Adapter] for more information.

In addition, the synchronizers for inbound channel adapters can now be provided with a `Comparator`.
This is useful when using `maxFetchSize` to limit the files retrieved.

The `CachingSessionFactory` has a new property `testSession` which, when true, causes the factory to perform a `test()` operation on the `Session` when checking out an existing session from the cache.

See xref:sftp/session-caching.adoc[SFTP Session Caching] and xref:ftp/session-caching.adoc[FTP Session Caching] for more information.

The outbound gateway MPUT command now supports a message payload with a collection of files or strings.
See xref:sftp/outbound-gateway.adoc[SFTP Outbound Gateway] and xref:ftp/outbound-gateway.adoc[FTP Outbound Gateway] for more information.

[[x51.-tcp]]
== TCP Support

When using SSL, host verification is now enabled, by default, to prevent man-in-the-middle attacks with a trusted certificate.
See xref:ip/ssl-tls.adoc#tcp-ssl-host-verification[Host Verification] for more information.

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

[[x5.1-twitter]]
== Twitter Support

Since the Spring Social project has moved to https://spring.io/blog/2018/07/03/spring-social-end-of-life-announcement[end of life status], Twitter support in Spring Integration has been moved to the Extensions project.
See https://github.com/spring-projects/spring-integration-extensions/tree/main/spring-integration-social-twitter[Spring Integration Social Twitter] for more information.

[[x51.-jms]]
== JMS Support

The `JmsSendingMessageHandler` now provides `deliveryModeExpression` and `timeToLiveExpression` options to determine respective QoS options for JMS message to send at runtime.
The `DefaultJmsHeaderMapper` now allows to map inbound `JMSDeliveryMode` and `JMSExpiration` properties via setting to `true` respective `setMapInboundDeliveryMode()` and `setMapInboundExpiration()` options.
When a `JmsMessageDrivenEndpoint` or `JmsInboundGateway` is stopped, the associated listener container is now shut down; this closes its shared connection and any consumers.
You can configure the endpoints to revert to the previous behavior.

See xref:jms.adoc[JMS Support] for more information.

[[x51.-http]]
== HTTP/WebFlux Support

The `statusCodeExpression` (and `Function`) is now supplied with the `RequestEntity<?>` as a root object for evaluation context, so request headers, method, URI and body are available for target status code calculation.

See xref:http.adoc[HTTP Support] and xref:webflux.adoc[WebFlux Support] for more information.

[[x51.-jmx]]
== JMX Changes

Object name key values are now quoted if they contain any characters other than those allowed in a Java identifier (or period `.`).
For example `org.springframework.integration:type=MessageChannel,` `name="input:foo.myGroup.errors"`.
This has the side effect that previously "allowed" names, with such characters, will now be quoted.
For example `org.springframework.integration:type=MessageChannel,` `name="input#foo.myGroup.errors"`.

[[x51.-micrometer]]
== Micrometer Support Changes

It is now simpler to customize the standard Micrometer meters created by the framework.
See xref:metrics.adoc#micrometer-integration[Micrometer Integration] for more information.

[[x51.-integration-graph]]
== Integration Graph Customization

It is now possible to add additional properties to the `IntegrationNode` s via `Function<NamedComponent, Map<String, Object>> additionalPropertiesCallback` on the `IntegrationGraphServer`.
See xref:graph.adoc#integration-graph[Integration Graph] for more information.

[[x51.-global-properties]]
== Integration Global Properties

The Integration global properties (including defaults) can now be printed in the logs, when a `DEBUG` logic level is turned on for the `org.springframework.integration` category.
See xref:configuration/global-properties.adoc[Global Properties] for more information.

[[x51.-poller-annotation]]
== The `receiveTimeout` for `@Poller`

The `@Poller` annotation now provides a `receiveTimeout` option for convenience.
See xref:configuration/annotations.adoc#configuration-using-poller-annotation[Using the `@Poller` Annotation] for more information.
