You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by fridlyos <al...@citi.com> on 2011/07/18 23:04:03 UTC

Camel JMS re-delivery on failure

Hi....

Hoping to get some help with an design issue I'm having.  Playing around
with Camel error handling - trying to get an answer to following questions.

If an exception is cough - message flows into exception handler.  If there
are few redelivery attempts to be made - Camel seem to handle it correctly. 
If, however, the systems fails during this time, the messages that were in
re-delivery process seem to be lost.

Is there a way to prevent that?  Basically, roll back transaction completely
all the way up to the Queue (not internally in Camel).


Any help is appreciated.

Thank you

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-JMS-re-delivery-on-failure-tp4601191p4601191.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Camel JMS re-delivery on failure

Posted by fridlyos <al...@citi.com>.
Thanks very much for the help.
Everything to work now.. I had an issue with an odlder version of camel not working with spring 3.0 (transaction not rolling back), but it seems to work with 2.7 and 3.0.5 (spring)

Thanks again...


--------------------------------------
Albert Friedland
(212) 816-8170
albert.friedland@citi.com

From: Ashwin Karpe [via Camel] [mailto:ml-node+4604046-1332030472-196626@n5.nabble.com]
Sent: Monday, July 18, 2011 5:38 PM
To: Friedland, Albert [ICG-IT]
Subject: Re: Camel JMS re-delivery on failure

Hi,

Rollback of transactions all the way back to the Queue happens only if the ActiveMQ consumer/producer that write to the queue/topic use a Transacted session in ActiveMQ.

When you create a connection factory, you need to set a Transaction Manager and a associated a Transaction against the JMS consumer. When the JMS consumer picks up the message and the session is transacted, then in case of failure to perform the route and in case of exception the message will reappear on the queue from where the consumer picked up the message...

Please find a working spring sample of how to create a transactional JMS Ccomponent below
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/AbstractTransactionTest.xml?view=co&content-type=text%2Fplain

(Note that there are 2 configurations shown) in the link above.

As for then using the transactional JMS component, please find a working transactional camel route below
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/XMLQueueToProcessorTransactionTest.xml?view=co&content-type=text%2Fplain

Cheers,

Ashwin...
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com

Blog:http://opensourceknowledge.blogspot.com
---------------------------------------------------------

________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Camel-JMS-re-delivery-on-failure-tp4601191p4604046.html
To unsubscribe from Camel JMS re-delivery on failure, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4601191&code=YWxiZXJ0LmZyaWVkbGFuZEBjaXRpLmNvbXw0NjAxMTkxfDE2NzEwNjQzMTE=>.


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-JMS-re-delivery-on-failure-tp4601191p4612719.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel JMS re-delivery on failure

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Rollback of transactions all the way back to the Queue happens only if the
ActiveMQ consumer/producer that write to the queue/topic use a Transacted
session in ActiveMQ.

When you create a connection factory, you need to set a Transaction Manager
and a associated a Transaction against the JMS consumer. When the JMS
consumer picks up the message and the session is transacted, then in case of
failure to perform the route and in case of exception the message will
reappear on the queue from where the consumer picked up the message...

Please find a working spring sample of how to create a transactional JMS
Ccomponent below
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/AbstractTransactionTest.xml?view=co&content-type=text%2Fplain
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/AbstractTransactionTest.xml?view=co&content-type=text%2Fplain 

(Note that there are 2 configurations shown) in the link above.

As for then using the transactional JMS component, please find a working
transactional camel route below
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/XMLQueueToProcessorTransactionTest.xml?view=co&content-type=text%2Fplain
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/XMLQueueToProcessorTransactionTest.xml?view=co&content-type=text%2Fplain 
 
Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-JMS-re-delivery-on-failure-tp4601191p4604046.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel JMS re-delivery on failure

Posted by Alistair Young <al...@uhi.ac.uk>.
FWIW this is what I did for a transactional route to stop messages disappearing from the original queue if the broker went down:

<beans ... >

  <broker xmlns="http://activemq.apache.org/schema/core"
					id="matrixBrokerID"
					brokerName="matrixBroker"
					useJmx="true"
					persistent="true">

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <route>
      <from uri="activemq:topic:topic1"/>
	<transacted />
	<to uri="activemq:topic:topic2"/>
    </route>
</camelContext>

	<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="matrixBrokerID">
		<property name="brokerURL" value="vm://matrixBroker?create=false"/>
	</bean>

	<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
		<property name="connectionFactory" ref="jmsConnectionFactory"/>
	</bean>

	<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
		<property name="connectionFactory" ref="jmsConnectionFactory"/>
		<property name="transacted" value="true"/>
		<property name="transactionManager" ref="jmsTransactionManager"/>
	</bean>

</beans>

Alistair



-- 
mov eax,1
mov ebx,0
int 80h




On 19 Jul 2011, at 06:51, Claus Ibsen wrote:

> On Mon, Jul 18, 2011 at 11:04 PM, fridlyos <al...@citi.com> wrote:
>> Hi....
>> 
>> Hoping to get some help with an design issue I'm having.  Playing around
>> with Camel error handling - trying to get an answer to following questions.
>> 
>> If an exception is cough - message flows into exception handler.  If there
>> are few redelivery attempts to be made - Camel seem to handle it correctly.
>> If, however, the systems fails during this time, the messages that were in
>> re-delivery process seem to be lost.
>> 
> 
> Yes Camel keeps in flight messages in memory
> 
>> Is there a way to prevent that?  Basically, roll back transaction completely
>> all the way up to the Queue (not internally in Camel).
>> 
> 
> You can use the Transactional Client EIP (aka transactions)
> http://camel.apache.org/transactional-client.html
> 
> A bit more here
> http://camel.apache.org/error-handling-in-camel.html
> 
> Chapter 9 in the Camel in Action book covers how to use transactions
> with Camel extensively.
> The source code for the book is freely available so they can be used
> for inspiration.
> 
> And FuseSource have a free excerpt of chapter 9 available at:
> http://fusesource.com/fuse/apache-books/
> The discount code listed on the page may have expired.
> 
> 
>> 
>> Any help is appreciated.
>> 
>> Thank you
>> 
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Camel-JMS-re-delivery-on-failure-tp4601191p4601191.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>> 
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/


Re: Camel JMS re-delivery on failure

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jul 18, 2011 at 11:04 PM, fridlyos <al...@citi.com> wrote:
> Hi....
>
> Hoping to get some help with an design issue I'm having.  Playing around
> with Camel error handling - trying to get an answer to following questions.
>
> If an exception is cough - message flows into exception handler.  If there
> are few redelivery attempts to be made - Camel seem to handle it correctly.
> If, however, the systems fails during this time, the messages that were in
> re-delivery process seem to be lost.
>

Yes Camel keeps in flight messages in memory

> Is there a way to prevent that?  Basically, roll back transaction completely
> all the way up to the Queue (not internally in Camel).
>

You can use the Transactional Client EIP (aka transactions)
http://camel.apache.org/transactional-client.html

A bit more here
http://camel.apache.org/error-handling-in-camel.html

Chapter 9 in the Camel in Action book covers how to use transactions
with Camel extensively.
The source code for the book is freely available so they can be used
for inspiration.

And FuseSource have a free excerpt of chapter 9 available at:
http://fusesource.com/fuse/apache-books/
The discount code listed on the page may have expired.


>
> Any help is appreciated.
>
> Thank you
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-JMS-re-delivery-on-failure-tp4601191p4601191.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/