首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >int-http:outbound-gateway reply-channel 'stalls‘

int-http:outbound-gateway reply-channel 'stalls‘
EN

Stack Overflow用户
提问于 2016-01-22 03:02:47
回答 1查看 688关注 0票数 3

我正在使用Spring Boot创建一个Spring集成原型。

我有一个“集线器”,它接受控制台输入,并将其发送到单独的socket/tcp应用程序。

tcp应用程序在其对集线器的回复中回显它被发送的内容。

然后,集线器接收tcp响应并将其发送到单独的restful/http应用程序。http应用程序回显被发送回集线器的内容。

我被阻塞在集线器的int- http :outbound-gateway上,它向http发送一个请求。当我省略‘回复通道’时,我可以输入多个文本并发送到tcp应用程序。该回复被转发到http应用程序,并在控制台中打印。但是,当我包含一个应答通道时,我可以发送一条消息到tcp应用程序( http应用程序接收到它),然后集线器应用程序‘停止’;我在控制台中输入消息,按下'enter‘,但没有任何反应。

这是我的配置:

代码语言:javascript
复制
    <!-- 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>

在其最终形式中,我希望将HTTP响应打印到某个地方,并将其转发到单独的AMQP应用程序。

EN

回答 1

Stack Overflow用户

发布于 2016-01-22 03:57:07

你的描述不是很清楚,但是,我猜,你是指这里的一些问题:

代码语言:javascript
复制
<int:service-activator id="inboutdHttpPrintServiceActivator"
    ref="inboundHTTPPrinterService"
    input-channel="from.http.pubsub.channel"
    method="printFromHttp"/>

如果能看到printFromHttp()的源代码就太好了,但是根据您的担心,这个方法似乎就是void

要将消息发送回标头中的replyChannel,您应该从服务方法中返回一些内容。看起来在你的例子中,同样的payloadmessage就足够了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34932194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档