Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Camel: What is actually being routed?

What is the "unit of promotion" or flow in an Apache Camel route? Meaning, what is the object that is actually being routed? A Message? An Exchange?

I ask because I thought that a Route consisted of 1+ Processor endpoints, and that an Exchange (containing a Message) was what actually gets routed across all the endpoints.

But it seems that Exchange can have both an inbound and an outbound Message, which indicates that messages can move through exchanges (as opposed to exchanges moving through processors/endpoints). Can someone help clarify why exchanges have in- and out-bound messages, and what routes are actually passing to each processor/endpoint?

like image 474
IAmYourFaja Avatar asked Jan 07 '13 12:01

IAmYourFaja


1 Answers

The exchange is simply a wrapper object around messages in a single route.

The in and out messages in an exchange is used to handle different exchange patterns (MEP).

Typically, this is used in processors/endpoints that return an answer (i.e. the request/response pattern), in Camel it's named InOut. Then the processor/component would read the request from the In parameter and set the response in the Out parameter. In the next step in the route Out would become In.

If you want to put a message somewhere and not worry about the response, you could use ExchangePattern.InOnly.

Even if you are in a processor and want to transform the message, you can operate on the In message and it will be copied to Out.

This is also described in the book Camel in Action chapter 1.

The routes are passing the message around, and the Exchange is an access object that is used to pass the message and access some global metadata.

like image 134
Petter Nordlander Avatar answered Oct 12 '22 23:10

Petter Nordlander