TCP: Connect Timeout; Close Stream

- Add `connectTimeout` to client connection factories
- Add `closeStreamAfterSend` to outbound gateway

* Polishing - PR Comments.
This commit is contained in:
Gary Russell
2019-06-05 14:38:14 -04:00
committed by Artem Bilan
parent cd075723e2
commit 466daa8774
22 changed files with 420 additions and 54 deletions

View File

@@ -410,6 +410,7 @@ Doing so causes the adapter to close the socket after sending the message.
The serializer does not, by itself, close the connection.
You should use this serializer only with the connection factories used by channel adapters (not gateways), and the connection factories should be used by either an inbound or outbound adapter but not both.
See also `ByteArrayElasticRawDeserializer`, later in this section.
However, since version 5.2, the outbound gateway has a new property `closeStreamAfterSend`; this allows the use of raw serializers/deserializers because the EOF is signaled to the server, while leaving the connection open to receive the reply.
NOTE: Before version 4.2.2, when using non-blocking I/O (NIO), this serializer treated a timeout (during read) as an end of file, and the data read so far was emitted as a message.
This is unreliable and should not be used to delimit messages.
@@ -814,6 +815,10 @@ remote-timeout-expression="headers['timeout']" -->
`client-mode` is not currently available with the outbound gateway.
Starting with version 5.2, the outbound gateway can be configured with the property `closeStreamAfterSend`.
If the connection factory is configured for `single-use` (a new connection for each request/reply) the gateway will close the output stream; this signals EOF to the server.
This is useful if the server uses the EOF to determine the end of message, rather than some delimiter in the stream, but leaves the connection open in order to receive the reply.
[[ip-correlation]]
=== TCP Message Correlation

View File

@@ -69,6 +69,13 @@ See <<./ip.adoc#tcp-codecs,Message Demarcation (Serializers and Deserializers)>>
When using a `TcpNioServerConnectionFactory`, priority is now given to accepting new connections over reading from existing connections, but it is configurable.
See <<./ip.adoc#note-nio,About Non-blocking I/O (NIO)>> for more information.
The outbound gateway has a new property `closeStreamAfterSend`; when used with a new connection for each request/reply it signals EOF to the server, without closing the connection.
This is useful for servers that use the EOF to signal end of message instead of some delimiter in the data.
See <<tcp-gateways>> for more information.
The client connection factories now support `connectTimeout` which causes an exception to be thrown if the connection is not established in that time.
See <<tcp-connection-factory>> for more information.
[[x5.2-mail]]
==== Mail Changes