Hi .. "myExchange" is not the queue name... When working with rabbitmq, you always send the message to a "RabbitMQ Exchange", which redirects it to some queue based on the routingKey (which is defined on the creation of the queue)... quite complex, but RabbitMQ component has different concepts than JMS and AMQP components.
In this case, the <from> in route1 is consuming from the "start" queue, and the <to> inside <onException> is sending to "errorMessage" queue (by the rabbitmq.ROUTING_KEY header), which is consumed by route2. The flow is working fine, the only problem is that I can't get the Exception "CAUGHT" nor "HANDLED" in route1, by the processor in route2. Em qua., 13 de nov. de 2019 às 16:55, WEIQUAN YUAN <weiquan.y...@gmail.com> escreveu: > why your from queue name is same as to queue name? > > On Wed, Nov 13, 2019 at 9:10 AM Alessandro Hoss <aleh...@gmail.com> wrote: > > > Hello guys, > > > > I've a route with onException, which sends the message to rabbitMQ, and > > another route listening rabbit to call a processor and get the exception > > thrown. I'm able to reach this processor, but i'm not able to get the > > exception thrown. > > > > I've tried with the <handled> property set to false, and with > > transferException=true query param on the endpoint uri's, but without > luck. > > > > On the "processorToGetExceptionData" i have tried both > > "exchange.getException()" and > > "exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class)", again > > without luck. > > > > Above are the (simplified) routes definitions: > > > > <route id="route1"> > > <from uri="rabbitmq:myExchange?queue=start&routingKey=start"/> > > <onException> > > <exception>java.lang.Exception</exception> > > <redeliveryPolicy maximumRedeliveries="2" > > redeliveryDelay="5000" retryAttemptedLogLevel="WARN"/> > > <handled> > > <constant>true</constant> > > </handled> > > <setHeader headerName="rabbitmq.ROUTING_KEY"> > > <constant>errorMessage</constant> > > </setHeader> > > <to uri="rabbitmq:myExchange?skipQueueDeclare=true"/> > > </onException> > > <process ref="processorThatThrowsSomeException"/> > > <to uri="anyEndpoint" /> > > </route> > > > > <route id="route2"> > > <from > > > uri="rabbitmq:myExchange?queue=errorMessage&routingKey=errorMessage"/> > > <process ref="processorToGetExceptionData"/> > > <to uri="anotherEndpoint"/> > > </route> > > > > Any ideas on what could be wrong ? > > > > Thanks in advance, > > Alessandro Hoss > > > > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Weiquan Yuan > Located in Ottawa, Canada > -- Alessandro Hoss