T.Rex
T.Rex

Reputation: 121

Camel Rest DSL - multicast and early reply to http client

Camel version is 2.18.1

I have the following routes:

1: A rest dsl accepting data from HTTP clients and sending it to the route below before replying to the client.

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

2: A multicast to route the command to two endpoints longRunningProces and shortRunningProcessWhichMustSendRespondToHttpClient.

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

How can I send to Http Client the response from the shortRunningProcessWhichMustSendRespondToHttpClient route ?

Upvotes: 2

Views: 1234

Answers (1)

rak22
rak22

Reputation: 338

Because you use multicast main thread is waiting for response.

use wireTap

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

route look like this

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

here is a complete code github

Upvotes: 1

Related Questions