Java Spring集成使用网关发送ack
我有一个生产者(写在CPP中),它向“SpringIntegrationServer”发送二进制数据。 它的工作原理如下: 现在我必须向制作人发送回复(如确认) 我读过关于网关的书,但实际上我很困惑。 我的配置是:Java Spring集成使用网关发送ack,java,spring,spring-integration,Java,Spring,Spring Integration,我有一个生产者(写在CPP中),它向“SpringIntegrationServer”发送二进制数据。 它的工作原理如下: 现在我必须向制作人发送回复(如确认) 我读过关于网关的书,但实际上我很困惑。 我的配置是: <int-ip:tcp-connection-factory id="serverTcpConFact" type="server" port="5566" using-nio="true" single-use="false" ta
<int-ip:tcp-connection-factory id="serverTcpConFact"
type="server"
port="5566"
using-nio="true"
single-use="false"
task-executor="myTaskExecutor"
deserializer="serializer"
serializer="serializer"/>
<int-ip:tcp-inbound-channel-adapter id="tcpInboundAdapter"
channel="tcpInbound"
connection-factory="serverTcpConFact" />
<int:channel id="tcpInbound" />
<int:service-activator
output-channel="tcpOutbound"
input-channel="tcpInbound"
ref="importService"
method="handler" />
<bean id="importService" class="my.ImportService" />
<int:channel id="tcpOutbound" />
<int:gateway id="mygateway"
service-interface="my.IpMyGatway"
default-request-channel="tcpInbound"
default-reply-channel="tcpOutbound"
default-reply-timeout="6000"/>
然后将每条消息的消息发送给生产者
多谢各位 我想知道为什么对你来说还不够
从服务
生成一条回复消息就足够了,网关将把它作为响应发送给客户端
简单示例:
<ip:tcp-inbound-gateway id="gatewaySerializedNio"
connection-factory="connectionFactory"
request-channel="serviceChannel" />
<channel id="serviceChannel" />
<service-activator input-channel="serviceChannel"
ref="service" method="process"/>
<beans:bean id="service" class="com.my.proj.MyService" />
MyService#process
方法的返回值将被序列化到TCP套接字。谢谢@Artem Bilan,但我不明白你对回复消息的意思。请你再举个例子好吗?在答案中加了一个例子
<ip:tcp-inbound-gateway id="gatewaySerializedNio"
connection-factory="connectionFactory"
request-channel="serviceChannel" />
<channel id="serviceChannel" />
<service-activator input-channel="serviceChannel"
ref="service" method="process"/>
<beans:bean id="service" class="com.my.proj.MyService" />