You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Marcin Cylke <mc...@touk.pl> on 2011/01/09 14:42:07 UTC

jms and transactional fetching

 Hi

 I've encountered a scenerio I'm unable to implement using Apache Camel.
 I want to have a component that polls messages from JMS queue and 
 processes
 them in some way. The problem is, there may be some problems, errors, 
 exceptions,
 and the processing fails. That's why I need to leave the message in the 
 queue, so
 the broker can retry it in some later time.

 I've used servicemix-jms, since I'm deploying the thing on Servicemix 
 (3.3), to
 achieve this. My config looks like this:

 #v+
     <jms:endpoint service="ts:WorkflowConsumerService"
                   endpoint="default"
                   targetService="ts:WorkflowConsumerCamelService"
                   targetEndpoint="default"
                   role="consumer"
                   processorName="jca"
                   connectionFactory="#connectionFactory"
                   resourceAdapter="#ra"
                   activationSpec="#activationSpec"
                   bootstrapContext="#bootstrapContext"
                   synchronous="true"
                   rollbackOnError="true"
                   wsdlResource="classpath:LeadManagement.wsdl"
                   defaultMep="http://www.w3.org/2004/08/wsdl/in-only"/>

     <bean name="connectionFactory" 
 class="org.springframework.jndi.JndiObjectFactoryBean">
         <property name="jndiName">
             <value>activemq/connectionFactory</value>
         </property>
     </bean>

     <bean name="ra" 
 class="org.springframework.jndi.JndiObjectFactoryBean">
         <property name="jndiName">
             <value>activemq/resourceAdapter</value>
         </property>
     </bean>

     <bean id="activationSpec" 
 class="org.apache.activemq.ra.ActiveMQActivationSpec">
         <property name="destination" value="example/C"/>
         <property name="destinationType" value="javax.jms.Queue"/>
         <property name="maximumRedeliveries" value="10"/>
         <property name="initialRedeliveryDelay" value="10000"/>
     </bean>

     <jee:jndi-lookup id="bootstrapContext" 
 jndi-name="java:comp/env/smx/BootstrapContext">
     </jee:jndi-lookup>
 #v-

 As you can see, I'm using activationSpec to configure redeliveries. I'd 
 like to know if this
 is possible to achieve using pure camel config? To this moment I've 
 only achieved retrying when
 the processing fails - I simply set connection to the broker as 
 transacted. But I don't
 know how to force the time between redeliveries and other things.

 Regards
 Marcin

Re: jms and transactional fetching

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

If you use transacted JMS then its the broker which handles
redeliveries and error handling and such.
So check the broker documentation.

For AMQ its such pages as
http://activemq.apache.org/message-redelivery-and-dlq-handling.html
http://activemq.apache.org/redelivery-policy.html

Check the AMQ in Action book.
Also the Camel in Action chapter 9 covers all about transactions with Camel.



On Sun, Jan 9, 2011 at 2:42 PM, Marcin Cylke <mc...@touk.pl> wrote:
> Hi
>
> I've encountered a scenerio I'm unable to implement using Apache Camel.
> I want to have a component that polls messages from JMS queue and processes
> them in some way. The problem is, there may be some problems, errors,
> exceptions,
> and the processing fails. That's why I need to leave the message in the
> queue, so
> the broker can retry it in some later time.
>
> I've used servicemix-jms, since I'm deploying the thing on Servicemix (3.3),
> to
> achieve this. My config looks like this:
>
> #v+
>    <jms:endpoint service="ts:WorkflowConsumerService"
>                  endpoint="default"
>                  targetService="ts:WorkflowConsumerCamelService"
>                  targetEndpoint="default"
>                  role="consumer"
>                  processorName="jca"
>                  connectionFactory="#connectionFactory"
>                  resourceAdapter="#ra"
>                  activationSpec="#activationSpec"
>                  bootstrapContext="#bootstrapContext"
>                  synchronous="true"
>                  rollbackOnError="true"
>                  wsdlResource="classpath:LeadManagement.wsdl"
>                  defaultMep="http://www.w3.org/2004/08/wsdl/in-only"/>
>
>    <bean name="connectionFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>        <property name="jndiName">
>            <value>activemq/connectionFactory</value>
>        </property>
>    </bean>
>
>    <bean name="ra" class="org.springframework.jndi.JndiObjectFactoryBean">
>        <property name="jndiName">
>            <value>activemq/resourceAdapter</value>
>        </property>
>    </bean>
>
>    <bean id="activationSpec"
> class="org.apache.activemq.ra.ActiveMQActivationSpec">
>        <property name="destination" value="example/C"/>
>        <property name="destinationType" value="javax.jms.Queue"/>
>        <property name="maximumRedeliveries" value="10"/>
>        <property name="initialRedeliveryDelay" value="10000"/>
>    </bean>
>
>    <jee:jndi-lookup id="bootstrapContext"
> jndi-name="java:comp/env/smx/BootstrapContext">
>    </jee:jndi-lookup>
> #v-
>
> As you can see, I'm using activationSpec to configure redeliveries. I'd like
> to know if this
> is possible to achieve using pure camel config? To this moment I've only
> achieved retrying when
> the processing fails - I simply set connection to the broker as transacted.
> But I don't
> know how to force the time between redeliveries and other things.
>
> Regards
> Marcin
>



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