java - Camel consume single message and stop, transacted -
i trying use camel consume single message jms queue in transacted manner. in flow this:
- wait until message published on jms queue
- try consume , process single message
- if processing fails (exception occurs), rollback consumption
- if processing passes, acknowledge , stop consuming anymore messages
- 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
Post a Comment