Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass exchange ID and originating route ID to a bean?

Exchange interface has getExchangeId() method which returns ID of an exchange. Is there a way to pass this value to a method of a bean when calling the bean from a route?

The same question is about ID of a route which originated an exchange. This value is returned by getFromRouteId() method of Exchange interface.

I know I could pass an Exchange object to the bean entirely. But it's undesirable to bind a bean to Camel API in my case.

like image 242
vect Avatar asked Dec 11 '25 05:12

vect


1 Answers

You can use the @Simple annotation bean parameter binding

   public void foo(@Simple("exchangeId") String id, 
                   @Simple("routeId") String routeId, 
                   Object body) { 
     ...
   }

Some links

  • http://camel.apache.org/simple
  • http://camel.apache.org/parameter-binding-annotations.html
like image 61
Claus Ibsen Avatar answered Dec 12 '25 19:12

Claus Ibsen