Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing values between processors in apache camel

Tags:

apache-camel

In apache camel, which of those is the best way to pass values from an exchange processor to another (and why) :

  • storing it in the exchange headers
  • using the setProperty method while building the route.
  • another way..
like image 832
kgautron Avatar asked Apr 26 '12 09:04

kgautron


People also ask

How do you pass a parameter to a Camel route?

As you mentioned, you can use a constructor (or setters or any other Java/Framework instruments) if the parameters are static from a Camel point of view. The parameters are configurable in the application, but after the application is started they do no more change.

How can we call processor in Camel?

Using a processor in a route Then you can easily call this processor from a Java such as: from("activemq:myQueue"). process(MyProcessor. class);

What is CamelContext in Apache Camel?

The CamelContext is the runtime system, which holds everything together as depicted in the figure below. The CamelContext provides access to many useful services, the most notable being components, type converters, a registry, endpoints, routes, data formats, and languages. Contains the components used.

What is routeId in Apache Camel?

routeId() are for identifying routes. By adding ids you can in your tests use adviceWith() to mock or inject or remove parts of your route to perform automated tests without having access to backend systems.


2 Answers

One distinction not mentioned by Ben and Petter is that properties are safely stored for the entire duration of the processing of the message in Camel. In contrast, headers are part of the message protocol, and may not be propagated during routing. For example, JMS has limitations what you can store as headers etc.

You may want to read the free chapter 1 of the Camel in Action book as it covers the Camel concepts with Exchange, Message, etc.

like image 159
Claus Ibsen Avatar answered Sep 28 '22 07:09

Claus Ibsen


Properties and headers are pretty much the same. Headers are, however, converted to/from protocol specific headers on certain components, such as Jms. So,

  • Meta data inside a route: properties
  • Meta data to/from outside: headers
like image 40
Petter Nordlander Avatar answered Sep 28 '22 06:09

Petter Nordlander