GH-3326: TCP: Support Unsolicited Server Messages

Resolves https://github.com/spring-projects/spring-integration/issues/3326

- OB Gateway - send unsolicited messages and late replies to a channel
- Support multiple `TcpSender` s

* Add channel variant to spec; code polishing
This commit is contained in:
Gary Russell
2020-07-06 15:05:57 -04:00
committed by GitHub
parent e2c6e77f2f
commit e919428680
10 changed files with 242 additions and 73 deletions

View File

@@ -910,6 +910,12 @@ This only applies when using the `TcpNetClientConnectionFactory`, it is ignored
IMPORTANT: When using a shared connection (`singleUse=false`), a new request, while another is in process, will be blocked until the current reply is received.
Consider using the `CachingClientConnectionFactory` if you wish to support concurrent requests on a pool of long-lived connections.
Starting with version 5.4, the inbound can be configured with an `unsolicitedMessageChannel`.
Unsolicited inbound messages will be sent to this channel, as well as late replies (where the client timed out).
To support this on the server side, you can now register multiple `TcpSender` s with the connection factory.
Gateways and Channel Adapters automatically register themselves.
When sending unsolicited messages from the server, you must add the appropriate `IpHeaders.CONNECTION_ID` to the messages sent.
[[ip-correlation]]
=== TCP Message Correlation
@@ -971,6 +977,10 @@ This default behavior was not appropriate in a truly asynchronous environment, s
You can reinstate the previous default behavior by setting the `so-timeout` attribute on the client connection factory to 10000 milliseconds.
=====
Starting with version 5.4, multiple outbound channel adapters and one `TcpInboundChannelAdapter` can share the same connection factory.
This allows an application to support both request/reply and arbitrary server -> client messaging.
See <<tcp-gateways>> for more information.
[[ip-headers]]
==== Transferring Headers
@@ -2054,6 +2064,11 @@ Only applies if the reply-channel might block (such as a bounded QueueChannel th
| `async`
|
| Release the sending thread after the send; the reply (or error) will be sent on the receiving thread.
| `unsolicited`
`MessageChannel`
|
| A channel to which to send unsolicited messages and late replies.
|===
.IP Message Headers

View File

@@ -35,6 +35,13 @@ See <<./redis.adoc#redis-stream-outbound,Redis Stream Outbound Channel Adapter>>
A Renewable lock registry has been introduced to allow renew lease of a distributed lock.
See <<./jdbc.adoc#jdbc-lock-registry,JDBC implementation>> for more information.
==== TCP Changes
Connection factories now support multiple sending components (`TcpSender`); they remain limited to one receiving component (`TcpListener`).
This allows, for example, an inbound gateway and outbound channel adapter to share the same factory, supporting both request/reply and arbitrary messaging from the server to the client.
Shared factories should not be used with outbound gateways, unless single-use connections or the `ThreadAffinityClientConnectionFactory` are being used.
See <<./ip.adoc#ip-collaborating-adapters,Collaborating Channel Adapters>> and <<./ip.adoc#tcp-gateways, TCP Gateways>> for more information.
[[x5.4-general]]
=== General Changes