2016-01-21 65 views
3

我使用Spring Boot創建Spring集成原型。int-http:outbound-gateway reply-channel'stalls'

我有一個'hub'接受控制檯輸入並將它發送到一個單獨的套接字/ tcp應用程序。

tcp應用程序回顯它在其對集線器的回覆中發送的內容。

集線器然後將tcp響應&發送給單獨的restful/http應用程序。 http應用程序回顯什麼被髮送回集線器。

我困在集線器的int-http:向http發送請求的出站網關。當我省略「回覆通道」時,我可以輸入多個文本併發送給tcp應用程序。該回覆被轉發到控制檯中打印的http應用程序&。但是,當我包含回覆通道時,我可以向tcp應用程序發送一條消息(http應用程序收到它),然後集線器應用程序「停止」;我在控制檯中鍵入消息,點擊「輸入」但沒有任何反應。

這裏是我的配置:

<!-- TO tcp application/server --> 
    <int:channel id="input" /> 

    <int:gateway id="simple.gateway" 
     service-interface="com.foo.SimpleGateway" 
     default-request-channel="input"/> 

    <int-ip:tcp-connection-factory id="client" 
     type="client" 
     host="localhost" 
     port="4444" 
     single-use="true" 
     so-timeout="10000"/> 

    <int-ip:tcp-outbound-gateway id="outGateway" 
     request-channel="input" 
     reply-channel="clientBytes2StringChannel" 
     connection-factory="client" 
     request-timeout="10000" 
     reply-timeout="10000"/>  

    <int:object-to-string-transformer id="clientBytes2String" 
     input-channel="clientBytes2StringChannel" 
     output-channel="broadcast.channel" /> 

    <int:channel id="broadcast.channel" /> 

    <int:recipient-list-router id="tcp.broadcast.list" 
     input-channel="broadcast.channel"> 
     <int:recipient channel="to.http" /> 
     <!-- other channels to broadcast to --> 
    </int:recipient-list-router> 

    <!-- TO HTTP restful endpoint --> 
    <!-- this sends the requests --> 
    <int:channel id="to.http" /> 

<!-- <int-http:outbound-gateway id="http-outbound-gateway" --> 
<!--  request-channel="to.http" --> 
<!--  url="http://localhost:8080/howdy?message={msg}" --> 
<!--  http-method="GET" --> 
<!--  expected-response-type="java.lang.String" --> 
<!--  charset="UTF-8"> --> 
<!--  <int-http:uri-variable name="msg" expression="payload"/> --> 
<!-- </int-http:outbound-gateway> --> 

    <int-http:outbound-gateway id="http-outbound-gateway" 
     request-channel="to.http" 
     url="http://localhost:8080/howdy?message={msg}" 
     http-method="GET" 
     expected-response-type="java.lang.String" 
     charset="UTF-8" 
     reply-channel="from.http.pubsub.channel"> 
     <int-http:uri-variable name="msg" expression="payload"/> 
    </int-http:outbound-gateway> 

<!-- http://docs.spring.io/spring-integration/reference/html/messaging-endpoints-chapter.html --> 
<int:publish-subscribe-channel id="from.http.pubsub.channel" /> 

<bean id="inboundHTTPPrinterService" 
     class="com.foo.service.InboundHTTPPrinterService"/> 

<int:service-activator id="inboutdHttpPrintServiceActivator" 
    ref="inboundHTTPPrinterService" 
    input-channel="from.http.pubsub.channel" 
    method="printFromHttp"/> 

</beans> 

它的最後形式,我想在某個地方打印並轉發到一個單獨的應用程序AMQP的HTTP響應。

回答

0

您的描述不清楚,不過,我想,你的意思是有些問題在這裏:

<int:service-activator id="inboutdHttpPrintServiceActivator" 
    ref="inboundHTTPPrinterService" 
    input-channel="from.http.pubsub.channel" 
    method="printFromHttp"/> 

這將是巨大看到printFromHttp()源代碼,而是根據你的恐懼似乎對於該方法是void

要發送消息回replyChannel的標題,你應該從你的服務方法返回一些東西。看起來就像你的情況一樣,如果是這樣的話,就是相同的​​或message

+0

這解決了「失速」的問題(我添加了一個字符串返回類型printFromHttp()。我現在我看到,是由TCP答覆不被記錄在我的「主」在那裏我發送消息,但之後來自http客戶的往返行程 – maspen

+0

正如我所說:你的描述不清楚,也許我們會考慮關閉這個'stalls'問題,並打開一個新的,更接近你目前的問題,並已經與它的環境呢?也考慮在這個問題上分享一些日誌/異常。對不起,我只是不明白你在這個問題中的這種信息。 –