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.
It is assumed that ʻautoStartUp is enabled, that is, ʻOutbound 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 ʻOutboundGateway in
Sender/
Listener as a sender / receiver (ʻOutboundGateway
implements TcpSender
/ TcpListener
). TcpSender
is the interface for establishing a connection from the connection factory to send a message, and TcpListener
is the interface for receiving the received message from the connection.ConnectionFactory
to start
.Message Gateway
.Message
with MessagingTemplate
and pass it to ʻOutbound Gateway via ʻAdvisedRequestHandler
. calls
ConnectionFactory` to establish a connection.ConnectionFactory
callsbuildNewConnection ()
of TcpConnection
to establish a new connection. When sharing a connection (single-use = false
), check first if there is already a usable connection. Publish an event when a new connection is established. holds
TcpConnection` in a variable.send
of TcpConnection
and serialize the message with Serializer
and send it to the host.Called between 6 and 7 if ʻInterceptor` is defined.
TcpConnection
causes MessageMapper
to map the received object to the message object.MessageMapper
edits the header and returns a message to TcpConnection
.TcpConnection
passes a message to ʻOutbound Gateway`. checks if the received message is tied to what was sent and passes it to ʻAsync Repry
. latch counts down or times out and returns a message to the ʻOutbound Gateway
. Receive processes 1 to 5 are executed asynchronously.single-use = true
), close the connection. In this case, an event is issued. returns the result in
Message Gateway`.Message Gateway
returns the result to Client.If ʻInterceptor is defined, it will be called at 3 before passing the message to ʻOutbound Gateway
.
Remarks:
Although omitted in the figure, there are Channel
and various endpoints between Message Gateway
and ʻOutbound Gateway`.
TCP communication will be performed using Spring Integration in the case, and the purpose of organizing the investigated results is I posted. There are few documents in Japanese, so I hope it helps those who are worried about it: sweat :. (By the way, the Server side does not plan to use Spring Integration in this project, so I will probably post it).
The figure above was created using a service called WebSequenceDiagrams. You can easily draw a sequence diagram with a script while looking at the sample. You can change the design and output it as an image. If you register your e-mail address, you can also save the data on the site. However, since the output image is low quality and the logo is included in the lower right (it seems that it can be solved by charging), it seems that it can not be used for commercial purposes, but it seems that it can be used to organize ideas.
Recommended Posts