activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: XA in standalone JMS client
Date Mon, 21 Aug 2006 07:50:27 GMT
You need to enlist resources with JTA. I'd suggest reading the JTA
javadoc and specification.

http://java.sun.com/j2ee/1.4/docs/api/javax/transaction/Transaction.html

On 8/21/06, Eugene Prokopiev <prokopiev@stc.donpac.ru> wrote:
> Hi,
>
> How can I use ActiveMQXA* classes in standalone JMS client? I tried to
> write this simple test:
>
> public class AMQXATest {
>
>         public static void main(String[] args) throws Exception {
>
>                 // start broker
>                 BrokerService broker = new BrokerService();
>                 broker.setPersistent(false);
>                 broker.addConnector("tcp://localhost:5000");
>                 broker.start();
>
>                 // start transaction manager
>                 TMService jotm = new Jotm(true, false);
>                 UserTransaction transaction = jotm.getUserTransaction();
>
>                 // start connection
>                 ActiveMQXAConnectionFactory connectionFactory =
>                         new ActiveMQXAConnectionFactory("tcp://localhost:5000");
>                 XAConnection connection = connectionFactory.createXAConnection();
>                 XASession session = connection.createXASession();
>          Destination destination = session.createQueue("messages.input");
>          MessageProducer producer = session.createProducer(destination);
>
>          // send message
>          TextMessage message = session.createTextMessage("Test Message
> String");
>          transaction.begin();
>          producer.send(message);
>          transaction.commit();
>          System.out.println("sent message : "+message.getJMSMessageID());
>
>          // close connection
>          session.close();
>          connection.close();
>         }
>
> }
>
> On running it I got:
>
> INFO  BrokerService - ActiveMQ null JMS Message Broker (localhost) is
> starting
> INFO  BrokerService - For help or more information please see:
> http://incubator.apache.org/activemq/
> INFO  TransportServerThreadSupport - Listening for connections at:
> tcp://prokopiev.stc.donpac.ru:5000
> INFO  TransportConnector - Connector tcp://prokopiev.stc.donpac.ru:5000
> Started
> INFO  BrokerService - ActiveMQ JMS Message Broker (localhost,
> ID:prokopiev.stc.donpac.ru-39870-1156143935533-0:0) started
> INFO  jotm - JOTM started with a local transaction factory which is not
> bound.
> INFO  jotm - CAROL initialization
> INFO  ConfigurationRepository - No protocols were defined for property
> 'carol.protocols', trying with default protocol = 'jrmp'.
> INFO  jta - JOTM 2.0.10
> INFO  ManagementContext - JMX consoles can connect to
> service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
> Exception in thread "main" javax.jms.JMSException: Session's XAResource
> has not been enlisted in a distributed transaction.
>         at
> org.apache.activemq.ActiveMQXASession.doStartTransaction(ActiveMQXASession.java:109)
>         at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1502)
>         at
> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:462)
>         at
> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:356)
>         at jta.AMQXATest.main(AMQXATest.java:40)
>
> How can I enlist Session's XAResource in a distributed transaction?
>
> --
> Thanks,
> Eugene Prokopiev
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Mime
View raw message