Hi there, 

I am using Camel 2.1.0, processing message from one ActiveMQ JMS queue. For
every message I process (whether succeed or fail), I send a status message
to a 2nd ActiveMQ queue. If processing fails, exception is thrown, message
rolls back to the original queue and we retry. I am using "transacted=true"
on all JMS endpoints, so that when I restart my Camel application, the
retried message survive restart and continue processing.

The problem is that when I throw exception (transaction not committed), the
status message is not written to the 2nd queue. A message is being retried
over and over, but status messages accumulate, they do not show up in status
message queue until the final successful retry (when transaction commits).

What I want is that when message rolls back because we throw exception, the
status still commits to the 2nd ActiveMQ queue right away. This is when
REQUIRES_NEW transaction comes in. However, I cannot figure out how to do
that. 

My processor logic using this to send status to ActiveMQ queue.  This is in
my process() logic for the 1st queue. 

                ProducerTemplate producerTemplate =
MyCamelContext.createProducerTemplate();
                producerTemplate.sendBodyAndHeader("StatusQueue", message, 
header,
value);

I wanted to start a transaction before this and commits transaction
afterwards, how do I do that?

I am seeing examples like the following, but it does not help me, because I
only want to start a new txn if an exception is going to be thrown, and
commits that transaction right before I throw exception.

from(...).transacted("PROPAGATION_REQUIRES_NEW").to(...)


--
View this message in context: 
http://camel.465427.n5.nabble.com/start-and-commit-transaction-before-ProducerTemplate-send-message-tp4686899p4686899.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to