Description
When using transferExchange="true" in a JMS consumer (assuming producer also did), camel is breaking the match between key and exchange in inflightRepository if allowUseOriginalMessage="true" is not set in camel context.
This can lead to java heap space out of memory because camel is not able to clear the inflightRepository from old Exchange.
Identified behaviour :
- Camel receive the JMS message
- If allowUseOriginalMessage=true : parse JMS message to build Exchange instance
- If not : generate a new Instance
- Camel add the Exchange to inflightRepository
- On accessing the ExchangeBody, if it was not parsed yet camel rebuild the Exchange but do not change the key(exchangeId) in the inflightRepository
- When the route process is over the message is not disposed if the key has been changed in the Exchange but not inflightRepository
- Sooner or later the heap space if full and application crash.
The problem appeared in 2.18.0 and is present up until 2.23.1 (tested with attached test case). Release note of 2.18.0 says :
"Optimize Camel to only enable AllowUseOriginalMessage if in use by error handler or OnCompletion<http://camel.apache.org/oncompletion.html>. End user who manually access the original message using the Java API must configure AllowUseOriginalMessage=true."
Problem is transferExchange="true" case also needs allowUseOriginalMessage="true" even if the not accessing original message by Java API an other way.
Easy work around : set allowUseOriginalMessage="true" in camel context configuration