2017-10-05 86 views
1

目前我们在我们的应用程序中使用Spring Integration 2.1.0版本。 申请流程如下:在应用程序执行从我们的应用程序使用Spring集成接收TCP服务器的确认集成

  1. 一些操作,我们通过Active MQ得到了在字符串输出字符串。
  2. 我已经使用消息驱动通道适配器和服务激活器从队列中读取数据。
  3. 使用tcp-outbound-gateway在服务器(应用程序作为客户端)上成功显示该数据。
  4. 问题是从服务器获取确认。
  5. 创建一个新频道,并在tcp-outbound-gateway中的回复频道中输入
  6. 在服务激活器中将相同频道作为输入频道传递。
  7. 它显示如下错误:

    [task-scheduler-5] 2017-10-05 18:32:20,732 ERROR org.springframework.integration.handler.LoggingHandler - org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers. 
    at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:108) 
    at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101) 
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61) 
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157) 
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128) 
    at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288) 
    at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149) 
    

代码是如下

<context:property-placeholder /> 

<!-- Gateway and connection factory setting --> 
<int:channel id="telnetLandingChannel" /> 

<int:channel id="telnetReplyChannel" /> 

<beans:bean id="clientCustomSerializer" 
    class="com.telnet.core.serializer.CustomSerializer"> 
    <beans:property name="terminatingChar" value="10" /> 
    <beans:property name="maxLength" value="65535" /> 
</beans:bean> 

<int:gateway id="gw" default-reply-channel="telnetReplyChannel" default-reply-timeout="100000" 
    service-interface="com.telnet.core.integration.connection.ParseTcpConfiguration$SimpleGateway" 
    default-request-channel="telnetLandingChannel"/> 

<ip:tcp-connection-factory id="clientFactory" 
    type="client" host="localhost" port="7777" single-use="false" using-nio="false" 
    serializer="${client.serializer}" deserializer="${client.serializer}" /> 

<ip:tcp-outbound-gateway id="clientInGw" 
    request-channel="telnetLandingChannel" 
    connection-factory="clientFactory" 
    reply-channel="telnetReplyChannel" 
    reply-timeout="100000"/> 

<!-- To send the messege over server via JMS and serviceActivator --> 
<int:channel id="incidentDispatchMessageChannel" /> 

<int:channel id="jmsChannel" /> 

<beans:bean id="customClientServiceActivator" 
    class= "com.telnet.core.integration.CustomClientServiceActivator"> 
</beans:bean> 


<int-jms:message-driven-channel-adapter id="incidentDispatchMessageChannelAdapter" error-channel="errorChannel" 
    connection-factory="mqConnectionFactory" 
    destination-name="${incident.processing.messaging.dispatch.queues}" 
    channel="incidentDispatchMessageChannel"/> 

<int:service-activator id="incidentMessageActivator" 
    input-channel="incidentDispatchMessageChannel" 
    output-channel="jmsChannel" 
    ref="customClientServiceActivator" method="getOutboundMessage"> 
</int:service-activator> 

<int:object-to-string-transformer id="clientBytes2String" 
    input-channel="jmsChannel" 
    output-channel="telnetLandingChannel"/> 

<!-- To receive the acknowledgement message on server via serviceActivator -->  
<int:service-activator id="incidentAck" 
    input-channel="telnetReplyChannel" 
    ref="customClientServiceActivator" method="getAck"> 
</int:service-activator> 

我已经研究了各种文章stackverFlow,但没能得到任何解决方案

回答

0

呀......这个错误并不清楚哪个频道是有罪的。

另一方面,你真的使用很老的Spring集成版本。 会很高兴考虑升级到最新版本:http://projects.spring.io/spring-integration/

但是,我认为这个问题在某种程度上正是reply-channel,你不仅使用<service-activator>,而且使用​​。

我建议你从网关定义中删除default-reply-channel="telnetReplyChannel",从<ip:tcp-outbound-gateway>定义中删除reply-channel="telnetReplyChannel"。让他们在请求期间通过由网关填充的replyChannel标题进行通信。

关于你<int-jms:message-driven-channel-adapter>流动,这导致同一<ip:tcp-outbound-gateway>,我建议仍然留在replyChannel头,但通过<header-enricher>这里填充它发送消息到telnetLandingChannel之前。那replyChannel通过<header-enricher>将完全是input-channel为后续<int:service-activator>处理从<ip:tcp-outbound-gateway>确认。

+0

我已经从default-reply-channel(网关)和reply-channel()中删除了telnetReplyChannel。 –

+0

我能够在AbstractReplyProducingMessageHandler.sendReplyMessage(Message replyMessage,final Object replyChannelHeaderValue)中看到有效负载中的确认消息(如byteArray),但replyChannelHeaderValue为null。请帮助.. –

+0

请在您的问题中通过编辑分享您的代码 –

0

我得到了这个问题的解决方案,在我们的代码中有多个xmls,但我已经添加了一个代码来显示stackOverflow中的流。 问题是我在xml中定义的,它只有配置部分,如出站适配器连接工厂,因为它应该在另一个xml中使用服务激活器进行定义。改变了频道定义的地方,它的工作。

我想断开TCP(作为服务器)的那一刻我收到了响应消息。截至目前我正在使用超时,所以我的TCP服务器会在超时时间结束后超时,但要求在TCP打印/显示确认时断开连接。请建议我如何实现这一点。

+0

请分享一些关于如何在显示服务器上的回复后断开serverconnect的指示,而无需等待超时时间。 –

相关问题