[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q] Camel header set in the fluent route builder gets lost

Hello Everybody!

I am relatively new to camel, so this might be a common mistake.
Also I am new to the mailing list, so please excuse me when I am doing something wrong here or if I am not sticking to the proper procedure.

I am trying to set up an application with several routes, inluding a scather-gather, and content-enricher.
A recepientList broadcasts a message to some query engines, they perform its task and send the result to the content enricher.
The content enricher needs to know from which engine the message is coming from, so he can properly enrich the message.
The content enricher will finally send the results to the aggregator.

To keep track where the message is coming from, I set the header in the query-engine-route by copying the value of the JMSDestination header.

I got the enricher working when I add it directly after the processor, but with an activemq:queue in between the exchange seems to loose the header I set earlier.
I can access the header in the query engine processor, but not anymore in the enricher processor.
I do only use exchange.getIn() in the processors, so this is not an exchange In/Out Problem like stated in the camel FAQs.
Also the header remains when I use constant() instead of getting the header dynamically with simple().

My route:
        // recipient list to broadcast the message

        //query engines (currently only one, but more to come):
                .setHeader("queryEngine", simple("${in.header.JMSDestination}")) 
                .process(new queryProcessor())
                .to ("activemq:queue:enricher");

        //content enricher adds a certain Schema to the query Results, depending on the query engine the message is coming from
                .process(new SchemaEnricher()) 

I know the quick fix would be to write something like .setHeader("queryEngine", constant("queryEngine1")) , but this would mean more maintenance when adding new query engines.
So I really like to do it this way (or any other way where I can track from where the message is coming from).
Setting the header in the query-engine-processor would be an option too, but I kinda want it visible in the route.

Thanks for your help and best regards!


( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03491.html on line 109
Call Stack
10.0017368696{main}( ).../msg03491.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03491.html on line 109
Call Stack
10.0017368696{main}( ).../msg03491.html:0