Thanks for the quick reply...my route looks like this (and this is the setup
I used when testing against Camel 2.0, with its <transacted/> element):

  <camelContext id="camelContext"
                xmlns="http://camel.apache.org/schema/spring";>
    <template id="producerTemplate"/>
    <endpoint id="testQueueA" uri="activemq:queue:test.queueA"/>
    <endpoint id="testQueueB" uri="activemq:queue:test.queueB"/>
    <route>
      <from uri="activemq:queue:test.queueA?concurrentConsumers=3"/>
      <transacted/>
      <bean ref="consumerThatAlsoProduces" method="onTestMessage"/>
    </route>
  </camelContext>

...and here's the code for my POJO consumer-that-also-produces:

public class ConsumerThatAlsoProduces {
    @Autowired
    ProducerTemplate producerTemplate;
    @Autowired
    @Qualifier("testQueueB")
    Endpoint testQueueB;
    
    public void onTestMessage(TestMessage msg) {
        producerTemplate.sendBody(testQueueB, ...a new message...);
    }
}


I see your point about having the outbound endpoint non-transacted, but I'd
prefer to have it send in a transaction.  Is there a way to tell Camel to
use a new transaction when using producerTemplate inside the existing
transaction?



Claus Ibsen-2 wrote:
> 
> Hi
> 
> What does your route look like?
> 
> Just a quick idea. Maybe in the producer template sendBody you could
> use a JMS endpoint where you set transacted=false.
> 
> 
> On Thu, Jun 4, 2009 at 6:43 PM, dcheckoway <[email protected]> wrote:
>>
>> Camel 1.6.1, ActiveMQ 5.2.0, Spring 2.5.6
>>
>> I have a POJO consumer that gets invoked by Camel for messages on an
>> ActiveMQ JMS queue.  It's set up as transacted (JMS transaction manager).
>> While my POJO is consuming a message, it needs to send a subsequent
>> message
>> (or several messages) to a different JMS queue.  I use
>> ProducerTemplate.sendBody to accomplish this...it works fine...except...
>>
>> My "complaint" is that the messages my consumer ends up sending don't
>> actually "appear" (in their respective JMS queue) until my consumer
>> returns
>> (commits?).
>>
>> Based on what I've read here (
>> http://activemq.apache.org/how-do-transactions-work.html ActiveMQ: How do
>> transactions work ) I'm convinced that ActiveMQ is buffering up the sent
>> messages until the consumer commits its transaction.  Something like that
>> --
>> I'm definitely not an expert on transactions...and that's why I'm posting
>> this.
>>
>> Is there any way to force an already-in-transaction consumer to use a
>> *separate* transaction when calling ProducerTemplate.sendBody?
>>
>> Is there another trick?
>>
>> My goal is to avoid the whole buffer-til-commit thing if possible, and
>> just
>> have those sent messages queued "immediately."
>>
>> Thanks in advance...
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-control-transactions-when-already-in-a-transaction-tp23873683p23873683.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-control-transactions-when-already-in-a-transaction-tp23873683p23874232.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to