ESBCOMP-38 Review transaction resume / suspend for async model.

master
David BRASSELY 2013-06-30 10:27:41 +02:00
parent 31c254c1ce
commit f14621cda6
2 changed files with 13 additions and 7 deletions

View File

@ -1060,6 +1060,7 @@ public class OutboundMessageProcessor {
Transaction transaction = (Transaction) outboundExchange.getProperty(
MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);
boolean txResumed = false;
boolean shouldSuspendTx = false;
if (transaction != null) {
if (mLog.isLoggable(Level.FINE)) {
mLog.log(Level.FINE, "Got transaction context from message exchange " + outboundExchange.getExchangeId() + ". About to resume transaction before the Dispatch call...");
@ -1218,6 +1219,7 @@ public class OutboundMessageProcessor {
}
}
}
shouldSuspendTx = true;
dispatch.invokeOneWay(soapMsg);
} else {
if (mMonitorEnabled) {
@ -1234,6 +1236,7 @@ public class OutboundMessageProcessor {
ctx.setProbe(callDispatchMeasurement);
AsyncResponseHandler<SOAPMessage> handler = AsyncResponseDispatcher.instance().getHandler(ctx);
dispatch.invokeAsync(soapMsg, handler);
shouldSuspendTx = true;
/*if (mMonitorEnabled) {
try {
LoggingMonitoringUtil.setCheckpoint(endpointMeta, trackingId, "Received-response-from-inout-remote-service", replySoapMsg.getSOAPPart().getEnvelope());
@ -1259,12 +1262,12 @@ public class OutboundMessageProcessor {
if (dispatch != null)
endpointMeta.releaseDispatch(dispatch);
if (txResumed) {
if (txResumed && shouldSuspendTx) {
if (mLog.isLoggable(Level.FINE)) {
mLog.log(Level.FINE, "Transction was resumed before the Dispatch call. Successfully received a SOAP response. " +
"About to suspend the transaction before sending the reply in the message exchange...");
}
//TransactionsUtil.suspendTransaction();
TransactionsUtil.suspendTransaction();
}
}
}

View File

@ -96,15 +96,17 @@ public class AsyncResponseProcessor<T> implements Runnable {
context.getEndpoint().getEndpointStatus().incrementReceivedReplies();
replyHTTP((DataSource) result);
} else {
final String err = Messages.getMessages(AsyncResponseProcessor.class).getString("HTTPBC-E1001");
logger.warning(err);
//final String err = Messages.getMessages(AsyncResponseProcessor.class).getString("HTTPBC-E1001");
suspendTransaction();
logger.warning("HTTPBC-E1001: Unsupported response media");
return;
}
try {
suspendTransaction();
context.getChannel().send(context.getInout());
} catch (MessagingException ex) {
final String err = Messages.getMessages(AsyncResponseProcessor.class).getString("HTTPBC-E1002");
logger.warning(err);
//final String err = Messages.getMessages(AsyncResponseProcessor.class).getString("HTTPBC-E1002");
logger.warning(new StringBuilder("HTTPBC-E1002: ").append(ex.getMessage()).toString());
}
} finally {
@ -272,7 +274,7 @@ public class AsyncResponseProcessor<T> implements Runnable {
private void resumeTransaction() {
javax.transaction.Transaction tx = (Transaction) context.getInout().getProperty(context.getInout().JTA_TRANSACTION_PROPERTY_NAME);
if (tx != null) {
TransactionsUtil.resumeTransaction(tx);
txResumed = TransactionsUtil.resumeTransaction(tx);
}
}
@ -280,6 +282,7 @@ public class AsyncResponseProcessor<T> implements Runnable {
try {
if (txResumed) {
TransactionsUtil.suspendTransaction();
txResumed = false;
}
} catch (SystemException ex) {/* I hope noone uses misterious XA*/