【问题标题】:Camel-netty4: how to wait response before send next requestCamel-netty4:如何在发送下一个请求之前等待响应
【发布时间】:2018-05-17 09:21:13
【问题描述】:

我已经创建了接受来自多个生产者的请求并通过使用带有请求-响应的 netty4 发送到远程服务器的路由。但是,当骆驼向远程服务器发送请求并等待响应时,会收到下一个传入请求并希望发送到远程服务器但由于骆驼无法接收响应而出现 IOException。

那么,如何设置 Camel-Netty4 发送请求并等待响应再发送下一个。

路由配置: 来自("direct:DirectProcessOut?block=true") .to("netty4:tcp://192.168.1.2:8000?sync=true&synchronous=true&reuseChannel=true")

【问题讨论】:

    标签: apache-camel netty


    【解决方案1】:

    实际上,我在尝试根据数据库表中的行一次发送多条消息时遇到了类似的问题。通话不会等待对方完成,实际上是互相踩踏,要么挂断,要么炸毁。

    我最终找到的解决方案是使用消息队列。接受您的请求并将它们路由到单个 activemq 路由中。

    比如:

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
           <from uri="direct:direct:DirectProcessOut"/>
           <to uri="activemq://processOutQueue"/>
        </route>
    </camelContext>
    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
           <from uri="activemq://processOutQueue"/>
           <to uri="netty4:tcp://192.168.1.2:8000?sync=true&amp;synchronous=true&amp;reuseChannel=true"/>
        </route>
    </camelContext>
    

    我的情况有点不同,所以我不确定这是否会保留您想要发送的信息。但希望它能给你一个开始的地方。

    【讨论】:

      猜你喜欢
      • 2020-08-06
      • 1970-01-01
      • 2015-07-15
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      相关资源
      最近更新 更多