【问题标题】:Call Camel servlet or jetty endpoint in fire-and-forget fashion以即发即弃的方式调用 Camel servlet 或码头端点
【发布时间】:2016-04-16 13:51:37
【问题描述】:

据我了解,骆驼中的 servlet 和码头端点都是一个请求回复消息交换 (InOut),期望一个输出消息。

因此,我假设当我向这些端点发送 HTTP 请求时,只有在路由的所有处理器完成后才会发回响应。

是否可以以即发即弃的方式调用这些端点,即只需触发路由并立即获得响应,而无需等待所有处理完成?

【问题讨论】:

标签: apache-camel


【解决方案1】:

当然,您只需在路由中添加一些asynchronous 步骤(EIP 或组件)...

例如...此路由会将所有请求发送到 JMS 队列(或 seda 等),该队列可以异步处理,并在消息进入队列后向 HTTP 客户端返回 ACK...

from("http://localhost:9001/inbound")
    .to("activemq:inboundQ");

from("activemq:inboundQ")
    .to(...inbound processing...);

【讨论】:

    【解决方案2】:

    最后,我使用“seda”使其异步。请注意,这仅在我使用 inOnly-tag 时运行异步:

    <route autoStartup="true" id="x-service">
         <from uri="servlet:/xService"/>
         <inOnly uri="seda:x-service-execute-async" />
         <transform>
             <constant>OK</constant>
         </transform>
     </route>
    
     <route autoStartup="true" id="x-service-execute-async">
         <from uri="seda:x-service-execute-async"/>
         ...
     </route>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-12
      • 2021-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多