java - Camel consume single message and stop, transacted -


i trying use camel consume single message jms queue in transacted manner. in flow this:

  1. wait until message published on jms queue
  2. try consume , process single message
  3. if processing fails (exception occurs), rollback consumption
  4. if processing passes, acknowledge , stop consuming anymore messages
  5. later in application lifecycle, process triggers consumption start again (1)

at first tried using polling consumer, using consumertemplate, can't figure out if possible transactionally - seems transaction internal consumertemplate regardless of message acknowledged consumed time consumertemplate returns.

can using consumertemplate? can using camel , if best approach (simple examples appreciated)?

i ended using pollenrich dsl achieve this. example route builder looks like:

from("direct:service-endpont").transacted("propogation_required").setexchangepattern(exchangepattern.inout).pollenrich("activemq:test-queue").bean(myhandler); 

i use direct endpoint service, sending "request" message direct endpoint polls jms queue single message (blocking if required). transaction started extends pollenrich if, example, myhandler bean fails message taken during pollenrich not consumed , left on queue.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -