This chapter provides an overview of the new features and improvements that have been introduced with Spring Integration 3.0 If you are interested in even more detail, please take a look at the Issue Tracker tickets that were resolved as part of the 3.0 development process.
TcpConnections now emit
TcpConnectionEvents) when connections are
opened, closed, or an exception occurs. This allows applications
to be informed of changes to TCP connections using the normal
AbstractTcpConnection has been renamed
TcpConnectionSupport; custom connections that
are subclasses of this class, can use its methods to publish events.
been renamed to
In addition, a new
is provided; by default, this adapter sends all
Further, the TCP Connection Factories, now provide a new method
getOpenConnectionIds(), which returns a list of identifiers for all
open connections; this allows applications, for example, to broadcast to all
Finally, the connection factories also provide a new method
closeConnection(String connectionId) which allows applications
to explicitly close a connection using its ID.
For more information see Section 16.5, “TCP Connection Events”.
Building on the 2.2
Integration 3.0 now introduces
TCP inbound channel adapters especially tailored
for receiving SYSLOG messages. For more information, see
Chapter 27, Syslog Support.
<int-jmx:tree-polling-channel-adapter/>is provided; this adapter queries the JMX MBean tree and sends a message with a payload that is the graph of objects that matches the query. By default the MBeans are mapped to primitives and simple Objects like Map, List and arrays - permitting simple transformation, for example, to JSON.
IntegrationMBeanExporternow allows the configuration of a custom
For more information, see Section 8.1, “JMX Support”.
File 'tail'ing inbound channel adapters are now provided to generate messages when lines are added to the end of text files; see Section 12.2.1, “'Tail'ing Files”.
<int:inbound-channel-adapter/> now supports
<script/> sub-elements to create a
MessageSource; see Section 3.3.3, “Channel Adapter Expressions and Scripts”.
The Content Enricher now provides configuration for
sub-elements, to enrich the outbound Message with headers based on the reply Message from the underlying
message flow. For more information see Section 6.2.3, “Payload Enricher”.
IntegrationEvaluationContextFactoryBean is provided to allow
configuration of custom
PropertyAccessors and functions for
use in SpEL expressions throughout the framework. For more information see Appendix A, Spring Expression Language (SpEL).
To customize the SpEL
EvaluationContext with static
Method functions, the new
component is introduced. Two built-in functions are also provided (
#xpath). For more information see Section A.3, “SpEL Functions”.
To customize the SpEL
<spel-property-accessors/> component is introduced.
For more information see Section A.4, “PropertyAccessors”.
The HTTP module now provides powerful Request Mapping support for Inbound Endpoints. Class
was replaced by
IntegrationRequestMappingHandlerMapping, which is registered under the bean name
integrationRequestMappingHandlerMapping in the application context. Upon parsing of the HTTP Inbound Endpoint,
IntegrationRequestMappingHandlerMapping bean is either registered or an existing bean is being reused.
To achieve flexible Request Mapping configuration, Spring Integration provides the
Both HTTP Inbound Endpoints are now fully based on the Request Mapping infrastructure that was introduced with Spring MVC 3.1.
For example, multiple paths are supported on a single inbound endpoint.
For more information see Section 15.4, “HTTP Namespace Support”.
A new Redis-based
implementation has been added. The
be used to maintain state of a
across application restarts. This new
implementation can be used with adapters such as:
New queue-based components have been added. The
<int-redis:queue-outbound-channel-adapter/> components are provided
to perform 'right pop' and 'left push' operations on a Redis List, respectively.
For more information see Chapter 22, Redis Support.
It is now possible to instruct the framework to store reply and error channels
in a registry for later resolution. This is useful for cases where
errorChannel might be lost; for example
a message. See Section 6.2.2, “Header Enricher” for more information.
In addition to the existing
eMongoDbMessageStore, a new
ConfigurableMongoDbMessageStore has been introduced.
This provides a more robust and flexible implementation of
It does not have backward compatibility, with the existing store,
but it is recommended to use it for new applications. Existing applications can use it, but messages
in the old store will not be available.
See Chapter 21, MongoDb Support for more information.
For more information see Section 7.2, “Messaging Gateways”.
AbstractCorrelatingMessageHandler provides a new property
to allow empty group expiry to run on a longer schedule than expiring partial groups. Empty groups will
not be removed from the
MessageStore until they have not been modified
for at least this number of milliseconds. For more information see Section 5.4.4, “Configuring an Aggregator”.
Previously, when a <filter/> had a <request-handler-advice-chain/>, the discard
action was all performed within the scope of the advice chain (including any downstream flow
discard-channel). The filter element now has an attribute
true), to allow the discard action to
be performed after the advice chain completes. See Section 7.7.4, “Advising Filters”.
Request Handler Advice Chains can now be configured using annotations. See Section 7.7.5, “Advising Endpoints Using Annotations”.
This transformer now correctly transforms
String. For more information see Section 6.1, “Transformer”.
Web Service Outbound Gateway 'uri' attribute now supports
<uri-variable/> substitution for all
URI-schemes supported by Spring Web Services. For more information see Section 29.4, “Outbound URI Configuration”.
The FTP, SFTP and FTPS endpoints no longer cache sessions by default.
cached-sessions attribute has been removed from all endpoints.
Previously, the embedded caching mechanism controlled by this attribute's value didn't
provide a way to limit the size of the cache, which could
grow indefinitely. The
CachingConnectionFactory was introduced in
release 2.1 and it became the preferred (and is now the only) way to cache sessions.
For more information, see
Section 13.6, “FTP Session Caching” and Section 25.3, “SFTP Session Caching”.
CachingConnectionFactory now provides a new method
resetCache(). This immediately closes idle sessions and causes in-use
sessions to be closed as and when they are returned to the cache.
DefaultSftpSessionFactory (in conjunction with a
CachingSessionFactory) now supports multiplexing channels over
a single SSH connection (SFTP Only).
Previously, there was no way to override the default filter used to process files retrieved
from a remote server. The
filter attribute determines which files are retrieved
FileReadingMessageSource uses an
AcceptOnceFileListFilter. This means that if a new copy of a file
is retrieved, with the same name as a previously copied file, no message was sent from the
With this release, a new attribute
local-filter allows you to override the
default filter, for example with an
AcceptAllFileListFilter, or some
other custom filter.
For users that wish the behavior of the
to be maintained across JVM executions, a custom filter that retains state, perhaps on
the file system, can now be configured.
Inbound Channel Adapters now support the
preserve-timestamp attribute, which
sets the local file modified timestamp to the timestamp from the server (default false).
local-filename-generator-expressionattribute is now supported, enabling the naming of local files during retrieval. By default, the same name as the remote file is used.
local-directory-expressionattribute is now supported, enabling the naming of local directories during retrieval based on the remote directory.
A new higher-level abstraction (
RemoteFileTemplate) is provided over the
Session implementations used by the FTP and SFTP modules. While it is
used internally by endpoints, this abstraction can also be used programmatically and, like all
*Template implemenations, reliably closes the underlying session while allowing
low level access to the session when needed.
Spring Integration 3.0 adds a new set of DDL scripts for MySQL version 5.6.4 and higher. Now MySQL supports fractional seconds and is thus improving the FIFO ordering when polling from a MySQL-based Message Store. For more information, please see Section 17.4.1, “The Generic JDBC Message Store”.
Payloads to persist or
merge can now be of type
In that case, each object returned by the
Iterable is treated as
an entity and persisted or merged using the underlying
NULL values returned by the iterator are ignored.
The JPA adapters now have additional attributes to optionally 'flush' and 'clear' entities from the associated persistence context after performing persistence operations.
For more information see Chapter 18, JPA Support.
JsonToObjectTransformernow emit/consume headers containing type information.
For more information, see 'JSON Transformers' in Section 6.1, “Transformer”.
<http:outbound-channel-adapter/>now provide an
encode-uriattribute to allow disabling the encoding of the URI object before sending the request.
<http:inbound-channel-adapter/>now have a
merge-with-default-convertersattribute to include the list of default
HttpMessageConverters after the custom message converters.
DefaultHttpHeaderMapper. Now, in addition correcting that issue,
DefaultHttpHeaderMapperprovides date parsing from formatted strings for any HTTP headers that accept date-time values.
<http:inbound-channel-adapter/>now support additional useful variables: #matrixVariables, #requestAttributes, #requestHeaders and #cookies. These variables are available in both payload and header expressions.
uri-variables-expressionattribute to specify an
Expressionto evaluate a
Mapfor all URI variable placeholders within URL template. This allows selection of a different map of expressions based on the outgoing message.
For more information see Chapter 15, HTTP Support.
Previously, the <int-amqp:outbound-gateway/> mapped headers before invoking the message
converter, and the converter could overwrite headers such as
outbound adapter maps the headers after the conversion, which means headers like
content-type from the outbound
Message (if present) are used.
Starting with this release, the gateway now maps the headers after the message conversion,
consistent with the adapter. If your application relies on the previous behavior (where the
converter's headers overrode the mapped headers), you either need to filter those headers
(before the message reaches the gateway)
or set them appropriately. The headers affected by the
content-encoding. Custom message converters
may set other headers.
Previously, the id attribute for elements within a
ignored and, in some cases, disallowed. Now, the id attribute is allowed
for all elements within a
<chain>. The bean names of chain elements is a combination
of the surrounding chain's id and the id of the element
itself. For example: 'fooChain$child.fooTransformer.handler'.
For more information see Section 5.6, “Message Handler Chain”.
Previously, when configuring a
<message-driven-channel-adapter/>, if you wished to
use a specific
TaskExecutor, it was necessary to declare a container
bean and provide it to the adapter using the
container attribute. The
task-executor is now provided, allowing it to be set directly on the adapter. This is
in addition to several other container attributes that were already available.
The RMI Inbound Gateway now supports an
error-channel attribute. See
Section 24.3, “Inbound RMI”.
For more complex database-specific types, not supported by the standard
CallableStatement.getObject method, 2 new additional
attributes were introduced to the
element with OUT-direction:
row-mapper attribute of the Stored Procedure Inbound Channel Adapter
now supports a reference to a
definition. Previously, it contained just a class name (which is still supported).
For more information see Section 17.5, “Stored Procedures”.
Previously, if an IMAP idle connection failed, it was logged but there was no mechanism to
inform an application. Such exceptions now generate
Applications can obtain these events using an
ApplicationListener configured to receive an
ImapIdleExceptionEvent or one of its super classes.
Previously, message ids were generated using the JDK
UUID.randomUUID() method. With this
release, the default mechanism has been changed to use a more efficient algorithm which
is significantly faster. In addition, the ability to change
the strategy used to generate message ids has been added.
For more information see the section called “Message ID Generation”.
You can now specify the transformer factory class name using the
transformer-factory-class attribute. See the section called “XsltPayloadTransformer”
The TCP connection factories now enable the configuration of a flexible mechanism to
transfer selected headers (as well as the payload) over TCP. A new
enables the selection of the headers, and an appropriate (de)serializer needs to be
configured to write the resulting
Map to the
TCP stream. A
MapJsonSerializer is provided as a convenient
mechanism to transfer headers and payload over TCP.
For more information see Section 16.8.4, “Transferring Headers”.
All Outbound Gateways (e.g.
are designed for 'request-reply' scenarios. A response is expected from the external service and
will be published to the
reply-channel, or the
replyChannel message header.
However, there are some cases where the external system might not always return a
result, e.g. a
<jdbc:outbound-gateway/>, when a SELECT ends with an empty
or, say, a Web Service is One-Way. An option is therefore needed to configure whether or not a
reply is required.
For this purpose, the requires-reply attribute has been introduced for Outbound Gateway components.
In most cases, the default value for requires-reply is
true and, if there is not any result,
ReplyRequiredException will be thrown. Changing the value to
means that, if an external service doesn't return anything, the message-flow will end at that point,
similar to an Outbound Channel Adapter.
The WebService outbound gateway has an additional attribute |
requiresReply property was previously present in the
but set to
false, and there wasn't any way to configure it on Outbound Gateways using the XML namespace.
Previously, a gateway receiving no reply would silently end the flow (with a DEBUG log message); with this change an
exception will now be thrown by default by most gateways. To revert to the previous behavior,
<delayer> provided a
to determine the delay value at runtime. In complex cases it was necessary
to precede the
<delayer> with a
Spring Integration 3.0 introduced the
expression attribute and
sub-element for dynamic delay determination. The
delay-header-name attribute is now deprecated
because the header evaluation can be specified in the
expression. In addition,
ignore-expression-failures was introduced to control the behavior when an
expression evaluation fails.
For more information see Section 7.4, “Delayer”.
Previously, sending to a <publish-subscribe-channel/> that had
no subscribers would return a
false result. If used in conjunction with
MessagingTemplate, this would result in an exception being thrown.
PublishSubscribeChannel has a property
minSubscribers (default 0). If the message is sent to at least the minimum
number of subscribers, the send is deemed to be successful (even if zero). If an application
is expecting to get an exception under these conditions, set the minimum subscribers to at
Retrieving gateways had no mechanism to specify the first record to be retrieved which
is a common use case. The retrieving gateways now support specifying this parameter
to the gateway definition. Section 18.6.3, “Retrieving Outbound Gateway”.
The JPA retrieving gateway and inbound adapter now have an attribute to specify the maximum
number of results in a result set as an expression. In addition, the
max-results attribute has been introduced to replace
max-number-of-results, which has been deprecated.
are used to provide the maximum number of results,
or an expression to compute the maximum number of results, respectively, in the
For more information see Chapter 18, JPA Support.
serializerproperty, with the raw data being the message payload.
topic-expressionproperty to determine the Redis topic against the Message at runtime.
topicsattribute, now has the
For more information, see Chapter 22, Redis Support.
FileListFilters that use a persistent
now available. These can be used to prevent duplicate files after a system restart. See
Section 12.2, “Reading Files”, Section 13.3, “FTP Inbound Channel Adapter”, and Section 25.5, “SFTP Inbound Channel Adapter” for more information.