无法使用spring TCP集成进行路由
我已经为TCP集成创建了入站和出站适配器,下面是给定的配置无法使用spring TCP集成进行路由,tcp,spring-integration,Tcp,Spring Integration,我已经为TCP集成创建了入站和出站适配器,下面是给定的配置 <beans:description> Uses conversion service and collaborating channel adapters. </beans:description> <context:property-placeholder /> <!-- Client side --> <gateway id="gw" ser
<beans:description>
Uses conversion service and collaborating channel
adapters.
</beans:description>
<context:property-placeholder />
<!-- Client side -->
<gateway id="gw"
service-interface="com.project.configuration.ACDGateway"
default-reply-timeout="20000" default-request-channel="input"
default-reply-channel="gatewayChannel" />
<ip:tcp-connection-factory id="client" type="client"
host="10.90.7.31" port="42027" single-use="false"
serializer="MessageSerializerDeserializerService" deserializer="MessageSerializerDeserializerService"
so-timeout="10000" />
<publish-subscribe-channel id="input" />
<ip:tcp-outbound-channel-adapter id="outAdapter.client"
order="1" channel="input" connection-factory="client" /> <!-- Collaborator -->
<beans:bean id="MessageSerializerDeserializerService"
class="com.project.service.impl.MessageSerializerDeserializerService" />
<ip:tcp-inbound-channel-adapter id="inAdapter.client"
channel="recieve" connection-factory="client" /> <!-- Collaborator -->
<channel id="recieve" />
<header-enricher input-channel="recieve"
output-channel="gatewayChannel">
<header name="replyChannel"
value="gatewayChannel"/>
</header-enricher>
<channel id="gatewayChannel" />
非常感谢您的帮助
谢谢,
Prashant您不能只添加
网关通道
作为回复通道头;replyChannel
头特定于每条消息,而gatewayChannel
则为每条消息桥接到它。您正在将replyChannel连接到自身;因此,堆栈溢出
您不能在此处使用通道适配器;您必须改用出站网关,以便框架可以维护replyChannel
头
显示了如何使用通道适配器实现类似结果的一种方法,方法是保存
replyChannel
并关联应答,但是使用网关实际上要简单得多。谢谢,但是当我不添加该头时,我在头异常中没有可用的输出通道。replyChannel
头被gw
网关用来关联对请求的回复。您必须从出站消息中保存该头,当收到回复时,找出它是针对哪个请求的,并恢复其replyChannel
头。正如我所说,如果您使用tcp出站网关而不是通道适配器,那么框架将为您解决所有这些问题。
Exception in thread "pool-3-thread-1" java.lang.StackOverflowError
at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:1090)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:239)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:88)
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:45)
at org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate.resolveDestination(AbstractDestinationResolvingMessagingTemplate.java:73)
at org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate.send(AbstractDestinationResolvingMessagingTemplate.java:67)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:300)
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:212)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:129)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:148)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:423)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:373)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate.send(AbstractDestinationResolvingMessagingTemplate.java:68)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:300)
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:212)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:129)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115)