Hi,

I would like to make an ActiveMQ participate in a XA Transaction. I have speial needs is that i may suspend a transaction and resume it in antoher thread. I am using spring for configuring all that together and its JmsTmplate. I saw http://activemq.apache.org/jms-and-jdbc-operations-in-one-transaction.html and http://jencks.org/Outbound+JMS , that seems fine to me. But I thought I could use JTOM as TM.
So maybe it is not the right place to ask but I do not know where else :(

I would like to know if there is a better solution to use XA with ActiveMQ because when I do a massive (never doing commit, just for test) rollback in my "transaction resuming threads" after one hour and a half of executing those threads (I am using Executors with a pool of 20 threads) I just receive java heap space. As I was using jencks/geronimo I tried the same with JTOM but the same happened. I am also using the new AMQPool from Jencks, because i do not know how else i could pool xa connections for activemq. I also saw an old thread speaking about http://issues.apache.org/activemq/browse/AMQ-303 but it seems it was moved to Jencks.

So please guys, is it better to use Jencks or JTOM?

Here is my sample config ...

<bean id="jmsResourceAdapter" class="org.apache.activemq.ra.ActiveMQResourceAdapter"> <property name="serverUrl"><value>${jms.brokerUrl}</value></property>
     </bean>

<bean id="transactionManager" class="org.jencks.factory.TransactionManagerFactoryBean"> <property name="defaultTransactionTimeoutSeconds"><value>${jms.transaction.timeout}</value></property>
   </bean>
<bean id="connectionFactory" class="org.jencks.amqpool.JcaPooledConnectionFactory"> <constructor-arg><value>${jms.brokerUrl}</value></constructor-arg> <property name="transactionManager" ref="transactionManager"/> <property name="maxConnections"><value>${jms.pool.maxConnections}</value></property>
   </bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
       <property name="connectionFactory" ref="connectionFactory"/>
<property name="receiveTimeout"><value>${jms.receive.timeout}</value></property>
   </bean>

*And the java suspend transaction code ...*

       TextMessage m = (TextMessage)template.receive(queueName);
               if( m != null){
tx = tm.suspend(); threadDisptacher.submit(new TxThread(tm, tx, m)); } else{ System.out.println("TIMEOUT : "+Thread.currentThread().getId());
                   tm.rollback();
               }

*And the TxThread when it starts it does ...*

try { tm.resume(tx); System.out.println("> SLEEP ... "+Thread.currentThread().getId());
           try {
               Thread.sleep(10000);
           } catch (InterruptedException e) {
           }
System.out.println("> SLEEP DONE "+Thread.currentThread().getId()); System.out.println(m); tm.rollback(); } catch (Throwable e) { e.printStackTrace();
           try {
               tm.rollback();
           } catch (Throwable e1) {
               e1.printStackTrace();
           }
       }

Sorry for this intrusion.

Kindly,
Daniel

Reply via email to