MessageContext msgToInvoke = null;
try {
StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();
RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
//starting a transaction
transaction = storageManager.getTransaction();
InvokerBean invokerBean = invokerBeanMgr.retrieve(messageContextKey);
String sequenceId = invokerBean.getSequenceID();
long messageNo = invokerBean.getMsgNo();
msgToInvoke = storageManager.retrieveMessageContext(messageContextKey, configurationContext);
RMMsgContext rmMsg = MsgInitializer.initializeMessage(msgToInvoke);
String sequencePropertyKey = SandeshaUtil.getSequencePropertyKey(rmMsg);
//endint the transaction before invocation.
transaction.commit();
boolean invoked = false;
try {
// Invocation is not done within a transation. This
// may get changed when WS-AT is available.
// Invoking the message.
msgToInvoke.setProperty(Sandesha2Constants.WITHIN_TRANSACTION,
Sandesha2Constants.VALUE_TRUE);
boolean postFailureInvocation = false;
// StorageManagers should st following property to
// true, to indicate that the message received comes
// after a failure.
String postFaulureProperty = (String) msgToInvoke
.getProperty(Sandesha2Constants.POST_FAILURE_MESSAGE);
if (postFaulureProperty != null
&& Sandesha2Constants.VALUE_TRUE.equals(postFaulureProperty))
postFailureInvocation = true;
AxisEngine engine = new AxisEngine(configurationContext);
if (postFailureInvocation) {
makeMessageReadyForReinjection(msgToInvoke);
if (log.isDebugEnabled())
log.debug("Receiving message, key=" + messageContextKey + ", msgCtx="
+ msgToInvoke.getEnvelope().getHeader());
engine.receive(msgToInvoke);
} else {
if (log.isDebugEnabled())
log.debug("Resuming message, key=" + messageContextKey + ", msgCtx="
+ msgToInvoke.getEnvelope().getHeader());
msgToInvoke.setPaused(false);
engine.resumeReceive(msgToInvoke);
}
invoked = true;
} catch (Exception e) {
if (log.isErrorEnabled())
log.error ("Exception :", e);
handleFault(msgToInvoke, e);
// throw new SandeshaException(e);
}
//starting a transaction for the post-invocation work.
transaction = storageManager.getTransaction();
// Service will be invoked only once. I.e. even if an
// exception get thrown in invocation
// the service will not be invoked again.
invokerBeanMgr.delete(messageContextKey);
// removing the corresponding message context as well.
MessageContext msgCtx = storageManager.retrieveMessageContext(messageContextKey, configurationContext);
if (msgCtx != null) {
storageManager.removeMessageContext(messageContextKey);