I’m using the Grails routing plugin which allows defining Camel routes with a Groovy DSL syntax very similar to the Java DLS syntax.
Suppose I have the following RouteBuilder:
class MyRoute extends RouteBuilder {
from('activemq:route1')
.to('someProcessor1')
.to('direct:route2')
from('direct:route2')
.to('someProcessor2')
onException(Throwable.class).useOriginalMessage().handled(true)
.to('activemq:route.failed')
}
If I have a message that starts at activemq:route1, then moves through direct:route2 but fails in the someProcessor2, then I end up with the message as it started at activemq:route1 in my activemq:route.failed queue… but that’s not what I want. If I have a failure in someProcessor2, I want the message as it started at direct:route2 (and likewise, if I have a failure in someProcessor1, I want the activemq:route1 message in my failed queue).
Is there any Apache Camel feature that allows me to “reset” the original message at the beginning of a RouteDefintion (i.e. from(<uri>))?
use something besides
direct:to join your routes (seda, vm, activemq) and it will behave as you suggested…otherwise, you can also explicitly preserve the relevant state of the message in a header and restore it in the onException clause, etc.