You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by danielaR <ro...@yahoo.com> on 2012/12/19 12:44:02 UTC

recipient list - send to all or none / transactions

Hello,
I am using Dynamic Recipient List to send a message to a list of recipients,
but I need to send it to all or none ( if I cannot send to one of the
recipients because of an error, then the message should not reach any of
them). 
In a previous solution (not using Camel, but EJBs), the sending was done in
a transaction, so I tried to apply the same solution and add transactions to
the jms component. However, I am getting this warning / error message:

MQJMSRA_DS4001: commit():Illegal for a non-transacted
Session:sessionId=20894783696602880

INFO:  WARN 806499 [Camel (camelContext) thread #4 -
JmsConsumer[jms/testQueue]] 
apache.camel.component.jms.DefaultJmsMessageListenerContainer  - Setup of
JMS message listener invoker failed for destination 'jms/testQueue' - trying
to recover. Cause: Could not commit JMS transaction; nested exception is
javax.jms.IllegalStateException: MQJMSRA_DS4001: commit():Illegal for a
non-transacted Session:sessionId=20894783696602880

This is my configuration (I have camel in a web application which I need to
deploy in glassfish).

<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
        <property name="configuration" ref="jmsConfig"/>
</bean>
<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration"> 
        <property name="connectionFactory" ref="myCamelConnectionFactory"/>
        <property name="transactionManager" ref="jmsTransactionManager"/>
        <property name="transacted" value="true"/>             
        <property name="destinationResolver">
            <bean
class="org.springframework.jms.support.destination.JndiDestinationResolver"/>
        </property>
</bean>
    
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
        <property name="connectionFactory" ref="myCamelConnectionFactory"/>
</bean>
<jee:jndi-lookup id="myCamelConnectionFactory"
jndi-name="jms/CamelConnectionFactory"/>

What am I missing? 
And Is this the correct solution for my problem - send to all or none in
recipientList -?

Thanks for your help.
Daniela Rotar



--
View this message in context: http://camel.465427.n5.nabble.com/recipient-list-send-to-all-or-none-transactions-tp5724360.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recipient list - send to all or none / transactions

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Dec 21, 2012 at 10:11 AM, danielaR <ro...@yahoo.com> wrote:
> Yes, thank you for that. I have no errors now, but I still can't find a way
> to implement The functionality that I need.
>
> I would like camel to send to all recipients in the recipientList in one
> Transaction.
>
> (Right now I think (or I see in the logs) that it starts a new transaction
> when it sends to a different destination. I would like it to send them all
> in the same transaction, so that when an error occurs and i rollback, none
> of the recipients receive the message).
>
> Is that even possible ? Can I so this with Camel or should I look into doing
> it with the Spring Transactions?
>

If its the same resources, such as the same JMS Broker etc. Then you
can do this in a single local transaction.
If you have 2+ resources involved you would need XA (2 phase commit),
and thats a beast to setup and get working.

And it the work needs to be done in the same thread as Spring TX uses
thread locals and whatnot for managing the TX.
Camel doesnt do the TX itself, but uses Spring TX under the covers.



>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipient-list-send-to-all-or-none-transactions-tp5724360p5724489.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: recipient list - send to all or none / transactions

Posted by danielaR <ro...@yahoo.com>.
Yes, thank you for that. I have no errors now, but I still can't find a way
to implement The functionality that I need. 

I would like camel to send to all recipients in the recipientList in one
Transaction. 

(Right now I think (or I see in the logs) that it starts a new transaction
when it sends to a different destination. I would like it to send them all
in the same transaction, so that when an error occurs and i rollback, none
of the recipients receive the message).
 
Is that even possible ? Can I so this with Camel or should I look into doing
it with the Spring Transactions? 



--
View this message in context: http://camel.465427.n5.nabble.com/recipient-list-send-to-all-or-none-transactions-tp5724360p5724489.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recipient list - send to all or none / transactions

Posted by Willem jiang <wi...@gmail.com>.
Please don't use the parallelProcessing.
As you know spring is using thread local to store the information of transaction, parallelProcessing will cause some trouble to let camel know the states of transaction.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Thursday, December 20, 2012 at 6:36 PM, danielaR wrote:

> This is my route  
> from("jms:camelQueue").
> transacted().
> process(validationProcessor).
> recipientList(header("recipientList")).
> parallelProcessing();
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipient-list-send-to-all-or-none-transactions-tp5724360p5724437.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: recipient list - send to all or none / transactions

Posted by danielaR <ro...@yahoo.com>.
This is my route 
from("jms:camelQueue").
                transacted().
                process(validationProcessor).
                recipientList(header("recipientList")).
                parallelProcessing();




--
View this message in context: http://camel.465427.n5.nabble.com/recipient-list-send-to-all-or-none-transactions-tp5724360p5724437.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recipient list - send to all or none / transactions

Posted by Willem jiang <wi...@gmail.com>.
We may need to take a look at your route.
From the exception I can tell is throw from JmsConsumer, I don't think it is related to the Recipient List.


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Wednesday, December 19, 2012 at 7:44 PM, danielaR wrote:

> Hello,
> I am using Dynamic Recipient List to send a message to a list of recipients,
> but I need to send it to all or none ( if I cannot send to one of the
> recipients because of an error, then the message should not reach any of
> them).  
> In a previous solution (not using Camel, but EJBs), the sending was done in
> a transaction, so I tried to apply the same solution and add transactions to
> the jms component. However, I am getting this warning / error message:
>  
> MQJMSRA_DS4001: commit():Illegal for a non-transacted
> Session:sessionId=20894783696602880
>  
> INFO: WARN 806499 [Camel (camelContext) thread #4 -
> JmsConsumer[jms/testQueue]]  
> apache.camel.component.jms.DefaultJmsMessageListenerContainer - Setup of
> JMS message listener invoker failed for destination 'jms/testQueue' - trying
> to recover. Cause: Could not commit JMS transaction; nested exception is
> javax.jms.IllegalStateException: MQJMSRA_DS4001: commit():Illegal for a
> non-transacted Session:sessionId=20894783696602880
>  
> This is my configuration (I have camel in a web application which I need to
> deploy in glassfish).
>  
> <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
> <property name="configuration" ref="jmsConfig"/>
> </bean>
> <bean id="jmsConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">  
> <property name="connectionFactory" ref="myCamelConnectionFactory"/>
> <property name="transactionManager" ref="jmsTransactionManager"/>
> <property name="transacted" value="true"/>  
> <property name="destinationResolver">
> <bean
> class="org.springframework.jms.support.destination.JndiDestinationResolver"/>
> </property>
> </bean>
>  
> <bean id="jmsTransactionManager"
> class="org.springframework.jms.connection.JmsTransactionManager">
> <property name="connectionFactory" ref="myCamelConnectionFactory"/>
> </bean>
> <jee:jndi-lookup id="myCamelConnectionFactory"
> jndi-name="jms/CamelConnectionFactory"/>
>  
> What am I missing?  
> And Is this the correct solution for my problem - send to all or none in
> recipientList -?
>  
> Thanks for your help.
> Daniela Rotar
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recipient-list-send-to-all-or-none-transactions-tp5724360.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).