问题
Why channel can be set on TcpReceivingChannelAdapter
, the inbound adapter, but not on TcpSendingMessageHandler
, the outbound adapter?
Why outbound adapter is called TcpSendingMessageHandler, why handler, not adapter?
One would intuitively expects that inbound adapter and outbound adapter would be "mirrors" of each other, just with different directions.
My question is variation of Spring Integration - Inbound vs Outbound Channel Adapters question, but focused on Spring Integration DSL API and Tcp/Ip socket communication.
回答1:
Consuming endpoints (service activator, outbound channel adapter, outbound gateway etc). Consist of two beans, a Consumer (type depends on the channel type) and a message handler.
The channel goes on the consumer which calls the handler when it gets a message.
When using java configuration, the @ServiceActivator
annotation triggers the creation of the consumer bean.
If you don't want to use annotations, add a ConsumerEndpointFactoryBean
to create the consumer (injecting the handler bean).
来源:https://stackoverflow.com/questions/55163586/tcpreceivingchanneladapter-vs-tcpsendingmessagehandler