Connection connection = activation.getConnection();
XAResource xaResource = null;
tm = activation.getTransactionManager();
// Get the endpoint
MessageEndpointFactory endpointFactory = activation.getMessageEndpointFactory();
// Create the session
if (activation.isDeliveryTransacted) {
if (connection instanceof XAConnection) {
log.debug("Delivery is transacted, and client JMS implementation properly implements javax.jms.XAConnection.");
xaSession = ((XAConnection) connection).createXASession();
session = xaSession.getSession();
xaResource = xaSession.getXAResource();
} else {
throw new Exception("Delivery is transacted, but client JMS implementation does not properly implement the necessary interfaces as described in section 8 of the JMS 1.1 specification.");
}
} else {
session = connection.createSession(false, spec.getAcknowledgeModeInt());
}
endpoint = endpointFactory.createEndpoint(xaResource);
// Set the message listener
session.setMessageListener(this);
}