[[migration-2.1-2.2]]
=== Changes between 2.1 and 2.2

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

[[x2.2-new-components]]
==== New Components

Version 2.2 added a number of new components.

[[x2.2-redis-store-adapters]]
===== `RedisStore` Inbound and Outbound Channel Adapters

Spring Integration now has `RedisStore` Inbound and Outbound Channel Adapters, letting you write and read `Message` payloads to and from Redis collections.
For more information, see <<./redis.adoc#redis-store-outbound-channel-adapter,RedisStore Outbound Channel Adapter>> and <<./redis.adoc#redis-store-inbound-channel-adapter,Redis Store Inbound Channel Adapter>>.

[[x2.2-mongo-adapters]]
===== MongoDB Inbound and Outbound Channel Adapters

Spring Integration now has MongoDB inbound and outbound channel adapters, letting you write and read `Message` payloads to and from a MongoDB document store.
For more information, see <<./mongodb.adoc#mongodb-outbound-channel-adapter,MongoDB Outbound Channel Adapter>> and <<./mongodb.adoc#mongodb-inbound-channel-adapter,MongoDB Inbound Channel Adapter>>.

[[x2.2-jpa]]
===== JPA Endpoints

Spring Integration now includes components for the Java Persistence API (JPA) for retrieving and persisting JPA entity objects.
The JPA Adapter includes the following components:

* <<./jpa.adoc#jpa-inbound-channel-adapter,Inbound channel adapter>>
* <<./jpa.adoc#jpa-outbound-channel-adapter,Outbound channel adapter>>
* <<./jpa.adoc#jpa-updating-outbound-gateway,Updating outbound gateway>>
* <<./jpa.adoc#jpa-retrieving-outbound-gateway,Retrieving outbound gateway>>

For more information, see <<./jpa.adoc#jpa,JPA Support>>.

[[x2.2-general]]
==== General Changes

This section describes general changes from version 2.1 to version 2.2.

[[x2.2-spring-31]]
===== Spring 3.1 Used by Default

Spring Integration now uses Spring 3.1.

[[x2.2-handler-advice]]
===== Adding Behavior to Endpoints

The ability to add an `<advice-chain/>` to a poller has been available for some time.
However, the behavior added by this affects the entire integration flow.
It did not address the ability to add (for example) retry to an individual endpoint.
The 2.2 release introduced the `<request-handler-advice-chain/>` to many endpoints.

In addition, we added three standard advice classes for this purpose:

* `MessageHandlerRetryAdvice`
* `MessageHandlerCircuitBreakerAdvice`
* `ExpressionEvaluatingMessageHandlerAdvice`

For more information, see <<./handler-advice.adoc#message-handler-advice-chain,Adding Behavior to Endpoints>>.

[[x2.2-transaction-sync]]
===== Transaction Synchronization and Pseudo Transactions

Pollers can now participate in Spring's Transaction Synchronization feature.
This allows for synchronizing such operations as renaming files by an inbound channel adapter, depending on whether the transaction commits or rolls back.

In addition, you can enable these features when no "`real`" transaction is present, by means of a `PseudoTransactionManager`.

For more information, see <<./transactions.adoc#transaction-synchronization,Transaction Synchronization>>.

[[x2.2-file-adapter]]
===== File Adapter: Improved File Overwrite and Append Handling

When using the file outbound channel adapter or the file outbound gateway, you can use a new `mode` property.
Prior to Spring Integration 2.2, target files were replaced when they existed.
Now you can specify the following options:

* `REPLACE` (default)
* `APPEND`
* `FAIL`
* `IGNORE`

For more information, see <<./file.adoc#file-writing-destination-exists,Dealing with Existing Destination Files>>.

[[x2.2-outbound-gateways]]
===== Reply-Timeout Added to More Outbound Gateways

The XML Namespace support adds the reply-timeout attribute to the following outbound gateways:

* AMQP Outbound Gateway
* File Outbound Gateway
* FTP Outbound Gateway
* SFTP Outbound Gateway
* WS Outbound Gateway

[[x2.2-amqp-11]]
===== Spring-AMQP 1.1

Spring Integration now uses Spring AMQP 1.1.
This enables several features to be used within a Spring Integration application, including the following:

* A fixed reply queue for the outbound gateway
* HA (mirrored) queues
* Publisher confirmations
* Returned messages
* Support for dead letter exchanges and dead letter queues

[[x2.2-jdbc-11]]
===== JDBC Support - Stored Procedures Components

====== SpEL Support

When using the stored procedure components of the Spring Integration JDBC Adapter, you can now provide stored procedure names or stored function names by using the Spring Expression Language (SpEL).

Doing so lets you specify the stored procedures to be invoked at runtime.
For example, you can provide stored procedure names that you would like to execute through message headers.
For more information, see <<./jdbc.adoc#stored-procedures,Stored Procedures>>.

====== JMX Support

The stored procedure components now provide basic JMX support, exposing some of their properties as MBeans:

* Stored procedure name
* Stored procedure name expression
* `JdbcCallOperations` cache statistics

[[x2.2-jdbc-gateway-update-optional]]
===== JDBC Support: Outbound Gateway

When you use the JDBC outbound gateway, the update query is no longer mandatory.
You can now provide only a select query by using the request message as a source of parameters.

[[x2.2-jdbc-message-store-channels]]
===== JDBC Support: Channel-specific Message Store Implementation

We added a new message channel-specific message store implementation, providing a more scalable solution using database-specific SQL queries.
For more information, see <<./jdbc.adoc#jdbc-message-store-channels,Backing Message Channels>>.

[[x2.2-shutdown]]
===== Orderly Shutdown

We added a method called `stopActiveComponents()` to the `IntegrationMBeanExporter`.
It allows a Spring Integration application to be shut down in an orderly manner, disallowing new inbound messages to certain adapters and waiting for some time to allow in-flight messages to complete.

[[x2.2-jms-og]]
===== JMS Outbound Gateway Improvements

You can now configure the JMS outbound gateway to use a `MessageListener` container to receive replies.
Doing so can improve performance of the gateway.

[[x2.2-o-t-j-t]]
===== `ObjectToJsonTransformer`

By default, the `ObjectToJsonTransformer` now sets the `content-type` header to `application/json`.
For more information, see <<./transformer.adoc#transformer,Transformer>>.

[[httpChanges]]
===== HTTP Support

Java serialization over HTTP is no longer enabled by default.
Previously, when setting an `expected-response-type` on a `Serializable` object, the `Accept` header was not properly set up.
We updated the `SerializingHttpMessageConverter` to set the `Accept` header to `application/x-java-serialized-object`.
However, because this could cause incompatibility with existing applications, we decided to no longer automatically add this converter to the HTTP endpoints.

If you wish to use Java serialization, you need to add the `SerializingHttpMessageConverter` to the appropriate endpoints by using the `message-converters` attribute (when you use XML configuration) or by using the `setMessageConverters()` method (in Java).

Alternatively, you may wish to consider using JSON instead.
It is enabled by having `Jackson` on the classpath.
