CPA
CPA

Reputation: 3063

How to route back to producer

I have a PoducerTemplate. With the template I want to send a message to a route. Within the route I want to process the message and then I want to get the result back.

The producer:

String response = producerTemplate.requestBody("direct:start", message, String.class);

The Route:

from("direct:start").process(...).to(?);

The question is, how should the route look like, to get the response after process?

Upvotes: 0

Views: 86

Answers (1)

anon
anon

Reputation:

There are two mindsets when thinking about getting the response from a route. One is the traditional Request/Reply pattern. This would be most appropriate when the last step in the route also follows this pattern. The typical case would be a web service call or http request. We would expect these components to return something, and that would be the value returned by the requestBody method.

The other is to take a traditional one-way route and simply have the last Out message returned. This would be done by setting the Exchange Pattern to InOut. A common use case for this might be for confirmation that the data placed at the last step meets certain criteria, or perhaps for auditing purposes.

Upvotes: 1

Related Questions