Continuing from the last time, in order to organize the flow of TCP communication with Spring Integration, I drew a sequence diagram on the client side, although it is complicated.
Last time: I checked the flow of TCP communication with Spring Integration (client edition)
It is assumed that ʻautoStartUp is enabled, that is, ʻInbound Gateway
and ConnectionFactory
are started when the application is started. That made the starting point strange: confounded :.
calls the method that sets
ConnectionFactory`.ConnectionFactory
registers ʻInbound Gateway in
Sender,
Listener as a sender / receiver (ʻInbound Gateway
implements TcpSender
, TcpListener
).ConnectionFactory
to start
.ServerSocketFactory
to generate ServerSocket
based on the specified port number.ServerSocket
and make Socket
wait for the connection to be accepted.TcpConnectionServerListeningEvent
.TcpConnection
based on the Socket
.TcpConnection
registers ʻInbound Gateway as a sender / receiver via
ConnectionFactory`. holds
TcpConnection`,TcpConnectionOpenEvent
.MessagingTemplate
, which is a template for telegram conversion and business processing.TcpConnection
.MessageMapper
.MessageMapper
extracts and returns the message payload.Remarks:
Although omitted in the figure, there are Channel
and various endpoints between MessagingTemplate
and ʻInbound Gateway`.
ConnectionExceptionEvent
if any exception occurs while the TCP connection is being established.Socket
.TcpConnection
asks ʻInbound Gateway` to remove the connection to disconnect from the list.ConnectionCloseEvent
.Processor
, which manages the LifeCycle
, to stop at the ʻInbound Gateway`. asks
ConnectionFactory` to stop.ConnectionFactory
closes ServerSocket
.TcpConnection
asks ʻInbound Gateway` to remove the connection to disconnect from the list. Also, if there are any remaining tasks, delete them as well.Remarks:
I mentioned that when some exception occurred in 1, but it refers to the case where Socket
is closed.
For more information [TcpNetConneciton # run
](https://github.com/spring-projects/spring-integration/blob/master/spring-integration-ip/src/main/java/org/springframework/integration/ip/ See tcp / connection / TcpNetConnection.java # L169).
The figure above was created using a service called WebSequenceDiagrams, continuing from the previous time.
Recommended Posts