}
protected boolean receiveAndExecute(Object invoker, 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);
Map<Class<?>, Object> mp = new HashMap<Class<?>, Object>();
mp.put(MessageEndpoint.class, ep);
ENDPOINT_LOCAL.set(mp);
ep.beforeDelivery(method);
messageReceived = doReceiveAndExecute(invoker, s, mc, null);
ep.afterDelivery();
} catch (Exception ex) {
throw new JMSException(ex.getMessage());
} finally {
if (ep != null) {
ep.release();
}
JmsUtils.closeMessageConsumer(mc);
JmsUtils.closeSession(xa);
JmsUtils.closeSession(s);
}