简体   繁体   中英

Apache Camel message scope

I have written a component (EHComponent) to do error handling for other components (AComponent).

AComponent reads from a queue, encounters an error, and if an exception is thrown, the message gets some headers about the error set, and a .to("error.queue") is called to put the message on another queue for the EHComponent to read from.

The EHComponent inspects the message headers referring to the error type, acts accordingly, setting some additional message headers (Counting how many times that message has made it to the error queue)

The EHComponent sets that value, then calls a .to("Original.Queue") which is what AComponent reads from.

The problem hasnt been fixed, so a new exception is thrown, so this same message goes through the process again.

The problem I am having is that the 2nd time through, even though I think it is the same message, those headers I set are not there.

I was under the impression that message headers are somewhat stable in Camel, so that even though I'm in a new exchange, the message will header would be intact. What do I have to do to ensure that a message header is accessible from any component, on any part of the route?

Thanks

Headers is part of the message, and as such its up to your transports to preserve headers. So when you send the messages over the queues using your component, then make sure you preserve headers.

However if you store properties on the Exchange, then they are kept for the lifetime of the Exchange.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM