Setting redelivery properties on XaConnectionFactory

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting redelivery properties on XaConnectionFactory

preben
Hi

I'm working on getting activemq to play nice with our Weblogic jee server, and have installed the Activemq rar 5.9.0 on WLS.
Activemq is running in it's own process, and not embedded in WLS

So far it works perfect even with XA and all, but now I'm trying to customize the redelivery policy pr. destination using camel + spring, and I'm getting a bit stuck here.

My spring config looks like this

<bean id="kaput" class="java.lang.RuntimeException" />

        <camelContext id="redelivery-Context" xmlns="http://camel.apache.org/schema/spring">
                <jmxAgent id="agent" createConnector="false" loadStatisticsEnabled="false" />
                <route id="redelivery-Route">
                        <from uri="activemq:queue:demo" />
                        <transacted />
                        <to uri="mock:demoevent" />
                        <throwException ref="kaput" />
                </route>
                <route id="file-feeder-Route">
                        <from uri="file://target/feed" />
                        <transacted />
                        <convertBodyTo type="java.lang.String" />
                        <to uri="activemq:queue:demo" />
                </route>

        </camelContext>

       
        <tx:jta-transaction-manager />
                       
       
        <jee:jndi-lookup  id="jmsConnectionFactory" jndi-name="activemq/ConnectionFactory" resource-ref="true" />
       
        <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
                <property name="connectionFactory" ref="jmsConnectionFactory" />
                <property name="transactionManager" ref="transactionManager"/>
        </bean>

As far as I can see I have to configure the Activation Specs or maybe set the redeliveryPolicy on the ActiveMQXAConnectionFactory.

The question is how to do that using Camel and Spring config ?

Best,
Preben
Reply | Threaded
Open this post in threaded view
|

Re: Setting redelivery properties on XaConnectionFactory

preben
A follow up for others.

It seems impossible to use the Activemq JCA adapter with ActivationSpecs pr. destination in a convenient way. There is also some talk about this here

Instead I gave up on the Resource Adapter, and set up XA support using plain Spring Config.

Now I'm able to use XA and at the same time configure QOS pr. destination in a more flexible way.


        <tx:jta-transaction-manager />
   

        <bean id="jmsTransactionManager" class="javax.transaction.TransactionManager" factory-bean="transactionManager" factory-method="getTransactionManager"/>
       
        <bean id="jmsXaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
        <property name="brokerURL" value="failover:(tcp://localhost:61616,tcp://localhost:61626)"/>
        <property name="redeliveryPolicy">
            <bean class="org.apache.activemq.RedeliveryPolicy">
                <property name="maximumRedeliveries" value="5"/>
            </bean>
        </property>
    </bean>
       
         <bean id="jmsTxConfig" class="org.apache.camel.component.jms.JmsConfiguration"> 
        <property name="connectionFactory" ref="pooledJmsXaConnectionFactory"/> 
        <property name="transactionManager" ref="transactionManager"/> 
        <property name="transacted" value="false"/>
        <property name="cacheLevelName" value="CACHE_CONNECTION"/>
    </bean> 
       
        <bean id="pooledJmsXaConnectionFactory" class="org.apache.activemq.pool.XaPooledConnectionFactory">
        <property name="maxConnections" value="1" /> 
        <property name="connectionFactory" ref="jmsXaConnectionFactory" />
        <property name="transactionManager" ref="jmsTransactionManager"/>
    </bean>
     
    <bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource">
        <property name="transactionManager" ref="jmsTransactionManager" />
        <property name="connectionFactory" ref="jmsXaConnectionFactory" /> 
        <property name="resourceName" value="activemq.default" />
    </bean>
           
        <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
                <property name="configuration" ref="jmsTxConfig" />
        </bean>
Reply | Threaded
Open this post in threaded view
|

Re: Setting redelivery properties on XaConnectionFactory

Richard Kettelerij
I wonder wether the RedeliveryPolicy on your XA ConnectionFactory works as
expected considering https://issues.apache.org/jira/browse/AMQ-4367.


On Thu, Mar 20, 2014 at 9:56 AM, preben <[hidden email]> wrote:

> A follow up for others.
>
> It seems impossible to use the Activemq JCA adapter with ActivationSpecs
> pr.
> destination in a convenient way. There is also some talk about this  here
> <
> http://stackoverflow.com/questions/7390908/can-apache-camel-connect-to-an-activationspec-in-websphere
> >
>
> Instead I gave up on the Resource Adapter, and set up XA support using
> plain
> Spring Config.
>
> Now I'm able to use XA and at the same time configure QOS pr. destination
> in
> a more flexible way.
>
>
>         <tx:jta-transaction-manager />
>
>
>         <bean id="jmsTransactionManager"
> class="javax.transaction.TransactionManager"
> factory-bean="transactionManager" factory-method="getTransactionManager"/>
>
>         <bean id="jmsXaConnectionFactory"
> class="org.apache.activemq.ActiveMQXAConnectionFactory">
>         <property name="brokerURL"
> value="failover:(tcp://localhost:61616,tcp://localhost:61626)"/>
>         <property name="redeliveryPolicy">
>             <bean class="org.apache.activemq.RedeliveryPolicy">
>                 <property name="maximumRedeliveries" value="5"/>
>             </bean>
>         </property>
>     </bean>
>
>          <bean id="jmsTxConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>         <property name="connectionFactory"
> ref="pooledJmsXaConnectionFactory"/>
>         <property name="transactionManager" ref="transactionManager"/>
>         <property name="transacted" value="false"/>
>         <property name="cacheLevelName" value="CACHE_CONNECTION"/>
>     </bean>
>
>         <bean id="pooledJmsXaConnectionFactory"
> class="org.apache.activemq.pool.XaPooledConnectionFactory">
>         <property name="maxConnections" value="1" />
>         <property name="connectionFactory" ref="jmsXaConnectionFactory" />
>         <property name="transactionManager" ref="jmsTransactionManager"/>
>     </bean>
>
>     <bean id="resourceManager"
> class="org.apache.activemq.pool.ActiveMQResourceManager"
> init-method="recoverResource">
>         <property name="transactionManager" ref="jmsTransactionManager" />
>         <property name="connectionFactory" ref="jmsXaConnectionFactory" />
>         <property name="resourceName" value="activemq.default" />
>     </bean>
>
>         <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>                 <property name="configuration" ref="jmsTxConfig" />
>         </bean>
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Setting-redelivery-properties-on-XaConnectionFactory-tp4679160p4679260.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Setting redelivery properties on XaConnectionFactory

preben
I have tested with redelivery of -1 and 5 and it seems to work in my case. Im getting infinite with -1 and 1+5 with redelivery of 5.

I seem to recall that redeliveryDelay is not respected, but I haven't tested it.

Other than that I got issues as described here http://activemq.2283324.n4.nabble.com/PooledConnectionFactory-stop-causes-org-apache-activemq-TransactionContext-to-be-declared-unhealthy-tc4679399.html


best,
Preben