use of javax.jms.TemporaryQueue in project aries by apache.
the class XaConnectionPool method createSession.
@Override
public Session createSession(boolean transacted, int ackMode) throws JMSException {
try {
boolean isXa = (transactionManager != null && transactionManager.getStatus() != Status.STATUS_NO_TRANSACTION);
if (isXa) {
// if the xa tx aborts inflight we don't want to auto create a
// local transaction or auto ack
transacted = false;
ackMode = Session.CLIENT_ACKNOWLEDGE;
} else if (transactionManager != null) {
// cmt or transactionManager managed
transacted = false;
if (ackMode == Session.SESSION_TRANSACTED) {
ackMode = Session.AUTO_ACKNOWLEDGE;
}
}
PooledSession session = (PooledSession) super.createSession(transacted, ackMode);
if (isXa) {
session.addSessionEventListener(new PooledSessionEventListener() {
@Override
public void onTemporaryQueueCreate(TemporaryQueue tempQueue) {
}
@Override
public void onTemporaryTopicCreate(TemporaryTopic tempTopic) {
}
@Override
public void onSessionClosed(PooledSession session) {
session.setIgnoreClose(true);
session.setIsXa(false);
}
});
session.setIgnoreClose(true);
session.setIsXa(true);
transactionManager.getTransaction().registerSynchronization(new Synchronization(session));
incrementReferenceCount();
transactionManager.getTransaction().enlistResource(createXaResource(session));
} else {
session.setIgnoreClose(false);
}
return session;
} catch (RollbackException e) {
final JMSException jmsException = new JMSException("Rollback Exception");
jmsException.initCause(e);
throw jmsException;
} catch (SystemException e) {
final JMSException jmsException = new JMSException("System Exception");
jmsException.initCause(e);
throw jmsException;
}
}
Aggregations