Reputation: 615
I have a camel route.
from(errorMultiDirect).routeId("errorMulticastTest")
.errorHandler(deadLetterChannel(mock)
.onPrepareFailure(errorProcessor).maximumRedeliveries(0))
.log(LoggingLevel.INFO, "Testing Error route")
.setHeader(OrderMessageConstants.WIMS_MSG_TYPE, simple("body[messageType]"))
.setHeader(OrderMessageConstants.SAP_MESSAGE_ID, simple("body[messageID]"))
.setHeader(OrderMessageConstants.ORDER_NUMBER, simple("body[orderHeader][order]"))
.multicast().parallelProcessing().shareUnitOfWork().stopOnException().to("direct:materialsTest", "direct:qmDocTest", "direct:sdsTest").end()
.to("log:com.sial.NotifyStatusLogger?level=INFO");
If an exception occurs in any of the multicast routes, like materaialsTest, the exception is caught in the multicast code, but the exception never gets sent to the dead letter channel. According to the documentation, setting shareUnitOfWork should make this happen, but it does not, nor does setting stopOnException. Am I missing something?
I have a second test route that doesn't use multicast, and it works as expected.
from(errorDirect).routeId("errorMaterialTest")
.errorHandler(deadLetterChannel(mock)
.onPrepareFailure(errorProcessor).maximumRedeliveries(0))
.log(LoggingLevel.INFO, "Testing Error route")
.setHeader(OrderMessageConstants.WIMS_MSG_TYPE, simple("body[messageType]"))
.setHeader(OrderMessageConstants.SAP_MESSAGE_ID, simple("body[messageID]"))
.setHeader(OrderMessageConstants.ORDER_NUMBER, simple("body[orderHeader][order]"))
.bean(materialsEnrichment)
.to("log:com.sial.NotifyStatusLogger?level=INFO");
This second route does send the message to the dead letter channel, when the materialsEnrichment bean throws an exception. This is the same bean that is called by the multicast route via "direct:materialsTest".
Upvotes: 2
Views: 1074
Reputation: 55525
You need to turn off error handling in the direct routes, as the dead letter channel is configured as route scoped error handler only in your route. Then failures form the direct routes should be handled by your route with the multicast.
from("direct:xxx")
.errorHandler(noErrorHandler())
Upvotes: 2