-
1. Re: ivalid transaction id
adrian.brock May 29, 2003 4:56 AM (in response to tmaster)Are you trying to use a session on two different
threads?
Post the stacktrace.
Regards,
Adrian -
2. Re: ivalid transaction id
tmaster May 30, 2003 12:00 AM (in response to tmaster)No, I am using this queue from one session.
Here is the part of stacktrace:
06:43:51,390 ERROR [STDERR] javax.jms.JMSException: Invalid transaction id.
06:43:51,406 ERROR [STDERR] at org.jboss.mq.SpyXAResourceManager.ackMessage(
SpyXAResourceManager.java:75)
06:43:51,406 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.preProcessMes
sage(SpyMessageConsumer.java:737)
06:43:51,406 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.receiveNoWait
(SpyMessageConsumer.java:367) -
3. Re: ivalid transaction id
adrian.brock May 30, 2003 7:46 AM (in response to tmaster)Post the code snippet that causes this problem.
Regards,
Adrian -
4. Re: ivalid transaction id
helgi May 30, 2003 10:38 AM (in response to tmaster)I'm getting the same error.
The same application is working fine in 3.0.6. But with 3.2.1 He says invalid transaction id.
In my scenario a sessionbean sends a message (the QueueSession is not transacted and it is set to autoacknowlegde). On the other side a MDB has to answer to the incoming message, but throws an invalid transaction id exception when it sends the answer.
The code in the MDB is the following:
QueueConnection queueConnection = null;
QueueSession session = null;
try {
Queue replyTo = (Queue) message.getJMSReplyTo();
QueueConnectionFactory factory = (QueueConnectionFactory) jndiContext.lookup("java:comp/env/jms/QueueFactory");
queueConnection = factory.createQueueConnection();
session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSender sender = session.createSender(replyTo);
Order theOrder = (Order) om.getObject();
Confirmation confirm = new Confirmation(theOrder);
Message answer = session.createObjectMessage(confirm);
sender.send(answer); // Exception occurs here
} catch (JMSException e) {
logger.error(e);
} catch (NamingException e) {
logger.error(e);
}
finally {
try {
session.close();
queueConnection.close();
} catch (JMSException e1) {
logger.error(e1);
}
}
Any idea?
Greets
helgi -
5. Re: ivalid transaction id
tmaster Jun 1, 2003 11:32 PM (in response to tmaster)My problematic code is there. Thank you for anyone who can help to find out the solution.
/*****************************************/
/*Writing to queue */
/*****************************************/
/* 1. set up */
QueueConnectionFactory queueConnectionFactory = (javax.jms.QueueConnectionFactory)ctx.lookup(
ContainerEnviroment.QUEUE_CONNECTION_JNDI);
queueConnection = queueConnectionFactory.createQueueConnection();
Queue docQueue = (javax.jms.Queue) ctx.lookup(ContainerEnviroment.DOC_REPORT_QUEUE_JNDI);
/* 2. Send message */
ctx = new InitialContext();
QueueSession queueSession = null;
QueueSender queueSender = null;
try {
ObjectMessage message = null;
// Create a session
queueSession =
queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// Create a Sender
queueSender = queueSession.createSender(docQueue);
long next_id = sequenceSessionLocal.getNextIdInSequence("DocReportId"); // new ID got from special store of sequences
// Create a message
message = queueSession.createObjectMessage();
message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
message.setJMSMessageID(Long.toString(next_id));
message.setObject(mesg); ///mesg is typically binary-type or text-type object
// Send it
queueSender.send(message);
} catch (JMSException ex) {
context.setRollbackOnly();
throw new EJBException(ex.toString());
} finally {
if (queueSession != null) {
try {
queueSession.close();
} catch (Exception e) {
}
}
}
}
/************************************/
/*Reading from the queue */
/*************************************/
private QueueConnection queueConnection = null;
private Queue documentQueue = null;
/*** init ***/
InitialContext ctx = null;
if(queueConnection == null) {
ctx = new InitialContext();
QueueConnectionFactory queueConnectionFactory = (javax.jms.QueueConnectionFactory)ctx.lookup(
ContainerEnviroment.QUEUE_CONNECTION_JNDI);
queueConnection = queueConnectionFactory.createQueueConnection();
documentQueue = (javax.jms.Queue) ctx.lookup(ContainerEnviroment.DOC_REPORT_QUEUE_JNDI);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
/***********************************
/*Reading (listing) from queue*/
/************************************/
QueueConnection connection;
Queue queue;
boolean browse;
QueueSession queueSession = null;
Vector list = null;
try {
queueSession = connection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
QueueBrowser browser = null;
if(browse)
browser = queueSession.createBrowser(queue);
Message m = null;
list = new Vector();
if(browse) {
Enumeration ren = browser.getEnumeration();
while(ren.hasMoreElements()) {
ObjectMessage om = (ObjectMessage)ren.nextElement();
Object obj = om.getObject();
list.add(obj);
}
browser.close();
} else {
while ((m = queueReceiver.receive()) != null) {
if (m instanceof ObjectMessage) {
ObjectMessage om = (ObjectMessage)m;
Object obj = om.getObject();
list.add(obj);
}
}
queueReceiver.close();
}
} catch(Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
} finally {
if(queueSession != null) {
try {
queueSession.close();
}catch(Exception e) { }
}
} -
6. Re: ivalid transaction id
adrian.brock Jun 2, 2003 4:43 AM (in response to tmaster)Neither of you are showing an XA ConnectionFactory,
so I'm guessing you are using java:/JmsXA
I've made the following configuration change to that
connection factory for 3.2.2, maybe this is
causing your problem? See jms-ds.xml
<security-domain-and-application>JmsXARealm</security-domain-and-application>
My first guess would be that the transaction
has timed out. 3.2.2 also contains improved
error reporting for the XAResource processing.
tmaster, your example code does not
match the stacktrace, there is no receiveNoWait.
Also a QueueBrowser does no transactional
work, which is probably why it works when
a receive fails.
I don't see anything special about the code,
I can spot some potential errors, but I doubt
they cause this problem.
You will have to explain the context in which
this code this runs.
3.2.2 is only available from cvs at the moment.
You'll probably need to send me an example
that reproduces this problem.
Regards,
Adrian