2017-10-05 83 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的指示,而無需等待超時時間。 –

相關問題