I have a camel route which reads in messages in batches from a queue, processes the message and proceeds to send them one by one to an api and awaits the api response.
I am having issue with retrieving the original message recieved at the start when a 500 response is thrown.
I thought that the splitter returns the original message?
Here is my route:
from(gatewayRouteConfig.getInputQueueEndpoint())
.process(process1)
.process(process2)
.setExchangePattern(ExchangePattern.InOnly)
.choice()
.when().jsonpath("Message", true)
.setBody(MESSAGE_WRAPPER_EXTRACTOR)
.end()
.split().method(messageSplitter, "splitMessages")
.log(INFO, "Received Message : ${body}")
.process(process3)
.process(validate)
.process(identity)
.process(requestProcessor) //where the exception is thrown and the original message that is used in the exception handler is picking up
.process(someService::gatewayResponseTimeStop)
.process(someService::endToEndResponseStop)
.process(someService::markGatewayDeliveryAsSuccess)
.log("Completed processing...");
and here is my exception handler in the same class:
private void configureExceptionHandlers() {
onException(ProviderException.class) //thrown when 500 error occurs
.useOriginalMessage() //picks message in the form the process(requestProcessor) method recieves it instead of start of route
.handled(true)
.log(ERROR, LOGGER, EXCEPTION_MESSAGE_WITH_STACKTRACE)
.to(DLQ);
Solved by adding shareUnitOfWork
.split().method(activityMessageSplitter, "splitActivityMessages").shareUnitOfWork()