Transaction is not active for commit (3.2.6)
osganian May 4, 2005 6:45 PMHi, I have 2 JBoss instances running. One is hosting my topic and JMS stuff. The other is trying to publish a message to that topic. If I set it up so that there is a durable subscription on that topic then I get the following error on my TopicSession.commit() call:
Caused by: javax.jms.JMSException: Transaction is not active for commit at org.jboss.mq.pm.Tx.commit(Tx.java:169) at org.jboss.mq.pm.TxManager.rollbackTx(TxManager.java:118) at org.jboss.mq.server.JMSDestinationManager.transact(JMSDestinationManager.java:458) at org.jboss.mq.server.JMSServerInterceptorSupport.transact(JMSServerInterceptorSupport.java:186) at org.jboss.mq.security.ServerSecurityInterceptor.transact(ServerSecurityInterceptor.java:182) at org.jboss.mq.server.TracingInterceptor.transact(TracingInterceptor.java:438) at org.jboss.mq.server.JMSServerInvoker.transact(JMSServerInvoker.java:186) at org.jboss.mq.il.uil2.ServerSocketManagerHandler.handleMsg(ServerSocketManagerHandler.java:166) at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:358) at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:377) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748) ... 1 more 2005-05-04 18:29:56,123 DEBUG [org.apache.catalina.core.StandardWrapper] Returning non-STM instance
Now, the message does gets published to the topic but this exception bubbles up and rolls back other stuff I need to do. Now if I didn't set up the topic to have a durable subscription then I don't get this error. What am I doing wrong here? The code to publish looks something like:
Destination destination =
(Destination)ServiceLocator.lookup(topicDestination);
ConnectionFactory jmsConnectionFactory =
(ConnectionFactory)ServiceLocator.lookup(connectionFactoryName);
Connection connection = null;
Session session = null;
MessageProducer sender = null;
boolean commit = false;
try {
// A topic
connection = ((TopicConnectionFactory)jmsConnectionFactory).
createTopicConnection(jmsUserName, jmsPassword);
session =
((TopicConnection)connection).createTopicSession(true,
Session.AUTO_ACKNOWLEDGE);
sender = ((TopicSession)session).createPublisher(
(Topic)destination);
for (Iterator iter = events.iterator(); iter.hasNext();) {
ObjectMessage message =
session.createObjectMessage((IEvent)iter.next());
((TopicPublisher)sender).publish(message);
}
commit = true;
} finally {
if (sender != null) {
sender.close();
}
if (session != null) {
if (commit) {
session.commit(); // Dies here if a durable subscription is set on the topic.
} else {
session.rollback();
}
session.close();
}
if (connection != null) {
connection.close();
}
}
Thanks for any help.
Mike