In that case you are going about it wrong. Camel has this support built in for you. If the route is declared to be transacted with .transacted(myRequirdPolicy) then camel will handle that all for you with that one line. Put the transacted line right after your exception handleing and before the main route and then go about your business. If you want a composite transaction that rolls back both the DB and JMS work then you will need to configure a jta transaction manager. Just google 'camel jta transacted route' and you will get code examples and so on.
On Saturday, December 21, 2013, Tarun Kumar wrote: > Thanks for replying. Here is my usecase: > > consume a message from the queue. Do some transformation on the messge. > Then, persist the transformed message to datastore. > Once, transformed message is written to datastore, send ack. Reason i want > to send ack later is, in case my application goes down post message > consumption and before writing to datastore, i should be able to fetch same > message again from JMS queue. Hope that clarifies. > > Thanks! > > > > On Sat, Dec 21, 2013 at 9:14 PM, kraythe . <kray...@gmail.com<javascript:;>> > wrote: > > > I don't think the question is quite clear. In JMS you can only consume a > > message off a queue once. You can't consume it and leave it on the queue. > > Why do want to not ack the message? Queues are like throwing candy into a > > room of kindergarten children. All will scramble for the candy but each > > piece will get consumed by only one child. The only time JMS messages > > aren't caked is when they are failed in delivery. And even then, the only > > use case for leaving them on the queue is because of a failed transaction > > in a transactional route, > > > > Tell me what is the use case you are trying to implement and I might be > > able to help you down another path. > > > > On Saturday, December 21, 2013, Tarun Kumar wrote: > > > > > Hi, > > > > > > Any help here will be highly appreciated. > > > > > > > > > On Fri, Dec 20, 2013 at 9:55 AM, Tarun Kumar < > agrawal.taru...@gmail.com <javascript:;> > > <javascript:;> > > > >wrote: > > > > > > > I am using polling consumer. > > > > > > > > from("timer://foo?period=5000").bean(cool, "someBusinessLogic"); > > > > > > > > public static class MyCoolBean { > > > > > > > > private ConsumerTemplate consumer; > > > > > > > > public void setConsumer(ConsumerTemplate consumer) { > > > > this.consumer = consumer; > > > > } > > > > > > > > public void someBusinessLogic() { > > > > > > > > Exchange exchange > > > > = > > > > > > consumer.receive("catalogJms:queue:queueName?mapJmsMessage=false&acknowledgementModeName=CLIENT_ACKNOWLEDGE"); > > > > > > > > } > > > > > > > > > > > > Even though i am not sending acknowledgement for received message, > each > > > > time it is polling different message. Any idea why that's happening? > > > > > > > > > > > > > -- > > *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* > > *Author of: Hardcore Java (2003) and Maintainable Java (2012)* > > *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 > > <http://www.linkedin.com/pub/robert-simmons/40/852/a39>* > > > -- *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of: Hardcore Java (2003) and Maintainable Java (2012)* *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 <http://www.linkedin.com/pub/robert-simmons/40/852/a39>*