【发布时间】:2018-03-23 12:50:38
【问题描述】:
我的要求是从 TCP 获取数据,从 TCP 获取数据后转换为 java 对象并在 ActiveMQ 上发送。发布后,需要在 TCP 上的同一通道上发送确认/响应代码。 为了满足这个要求,我使用 tcp-outbound-gateway 作为双向通信。
问题是我无法使用 ActiveMQ 发送确认。如果我注释掉 ActiveMQ 部分并在 replyChannel 上写一个虚拟字符串,它是可见的,但是当我在 Active MQ 队列上发送对象时,它会给我一条消息“收到空回复,没有发送任何内容” .
我正在使用一个新队列来获取确认并尝试将响应放在 tcp-outbound-gate 的回复通道上,但错误消息是 没有可用的输出通道或回复通道标头。 em>
我通过传入消息获得了 MessageHeaders 详细信息,并通过队列发送它以使用 copyHeader。我可以设置标头并在 Message 对象中查看 paylod,通过在回复通道上应用 Interceptos 验证相同,但仍然收到相同的错误 没有可用的输出通道或回复通道标头。
代码是:
<int:gateway id="gw" default-reply-channel="replyChannel" default-reply-timeout="10000" service-interface= "com.telnet.core.integration.connection.ParseTcpConfiguration$SimpleGateway"
default-request-channel="${server.inboundChannel}"/>
<int:channel id="telnetLandingChannel" />
<ip:tcp-connection-factory id="serverFactory" type="server" host="${server.host}" port="${server.port}" single-use="false"
serializer="${server.serializer}" deserializer="${server.serializer}" task-executor="serverFactoryTaskExecutor"/>
<ip:tcp-inbound-gateway id="serverInboundAdpater" request-channel="telnetLandingChannel" reply-channel="replyChannel"
connection-factory="serverFactory" error-channel="errorChannel" reply-timeout="1000000" auto-startup="false"/>
<int:channel id="replyChannel"></int:channel>
<beans:bean id="acknowledgementHandler" class= "com.telnet.core.integration.AcknowledgementHandler">
</beans:bean>
<int:channel id="incidentDispatchMessageChannel" datatype="${incident.interaction.dispatch.response.datatype}"></int:channel>
<int-jms:message-driven-channel-adapter id="incidentDispatchMessageChannelAdapter" error-channel="errorChannel"
connection-factory="mqConnectionFactory"
destination-name="${incident.processing.tcp.dispatch.response.queues}"
channel="incidentDispatchMessageChannel"/>
<int:transformer id="incidentMessageActivator"
input-channel="incidentDispatchMessageChannel"
output-channel="replyChannel"
ref="acknowledgementHandler" method="incidentAck">
</int:transformer>
public Message incidentAck(final DefaultIncidentAcknowledgeMessage defaultIncidentAcknowledgeMessage){
MessageHeaders ms = (MessageHeaders)defaultIncidentAcknowledgeMessage.getProperties().get("MessageHeader");
Message<String> message = MessageBuilder.withPayload("1").copyHeaders(ms).build();
return message;
}
【问题讨论】:
标签: tcp spring-integration activemq