-
1. Re: Transactions + camel + activemq?
njiang Jul 28, 2011 9:02 PM (in response to jamie3_james.archibald)If you mark the route as .transacted(), when you throw the exception from your process, the jms template will not commit the transaction, and the message will still in the queue.
It makes senesce that you get the timeout exception.
Willem
-
2. Re: Transactions + camel + activemq?
davsclaus Jul 29, 2011 2:18 AM (in response to jamie3_james.archibald)You need to enable transferException to use the exception as the reply.
See more details at
from("direct:somewhere") .to("activemq:queue:destination?transferException=true") from("activemq:queue:destination?transferException=true") .process(new Processor() { // client should receive exception immediately but instead we get a JMS timeout exception throw new RuntimeException("transaction failed"); });
-
3. Re: Transactions + camel + activemq?
jamie3_james.archibald Jul 29, 2011 6:21 AM (in response to davsclaus)The "transferException=true" parameter worked once it was placed on the consumer and producer. Previously I only had it set on the consumer side and it didn't work.
Much thanks
-
4. Re: Transactions + camel + activemq?
davsclaus Jul 29, 2011 8:13 AM (in response to jamie3_james.archibald)Yeah I think you need it on both sides. The producer so it knows that an exception may be returned in the JMS message. And on the consumer side, so it knows, that it should send back the exception in the JMS message.
-
5. Re: Transactions + camel + activemq?
jamie3_james.archibald Aug 4, 2011 9:46 AM (in response to davsclaus)Would be good to make sure in the documentation it says to add it to the consumer and producer.
Also I have one more question. In the above example my transacted POJO throws PSQLExceptions which are serialized and sent back to the client. however the client doesn't have the PSQLException class in its classpath so I get class not found exceptions and in turn a timeout still occurs.
Is there a way to tell camel how to transfer the exchange? Ideally I dont want to transfer the PSQLException back to the client, but instead maybe a RuntimeException. This could be executed in some custom code.
-
6. Re: Transactions + camel + activemq?
davsclaus Aug 4, 2011 10:43 AM (in response to jamie3_james.archibald)You can use onException on the broker side to catch and handle that PSQLExcpetion and set some other kind of exception.