Camel Rest DSL - 多播和早期回复http客户端

时间:2017-01-11 21:55:46

标签: rest apache-camel

Camel版本是2.18.1

我有以下路线:

1:休息dsl接受来自HTTP客户端的数据并将其发送到路由 在回复客户之前。

rest("/api")
    .post("/commands/{command}").to("direct:commands")

2:将命令路由到两个端点longRunningProcesshortRunningProcessWhichMustSendRespondToHttpClient的多播。

from("direct:commands")
    .multicast()
        .to("direct:longRunningProces")
        .to("direct:shortRunningProcessWhichMustSendRespondToHttpClient");

如何向Http客户端发送shortRunningProcessWhichMustSendRespondToHttpClient路由的响应?

1 个答案:

答案 0 :(得分:0)

因为你使用组播主线程正在等待响应。

使用wireTap

http://camel.apache.org/wire-tap.html

路线看起来像这样

from("direct:commands")
.wireTap("direct:longRunningProces") //<<- seperate thread to process this route
    .to("direct:shortRunningProcessWhichMustSendRespondToHttpClient");

这是一个完整的代码 github