@Override
protected boolean receiveAndExecute(Session session, MessageConsumer consumer)
throws JMSException {
boolean messageReceived = false;
MessageEndpoint ep = null;
MessageConsumer mc = null;
XASession xa = null;
Session s = null;
try {
xa = (XASession)createSession(getSharedConnection());
XAResource xar = xa.getXAResource();
s = xa.getSession();
mc = s.createConsumer(getDestination());
ep = factory.createEndpoint(xar);
ENDPOINT_LOCAL.set(ep);
ep.beforeDelivery(method);
messageReceived = doReceiveAndExecute(s, mc, null);
ep.afterDelivery();
} catch (Exception ex) {
throw new JMSException(ex.getMessage());
} finally {
ep.release();
JmsUtils.closeMessageConsumer(mc);
JmsUtils.closeSession(xa);
JmsUtils.closeSession(s);
}