diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-03 14:27:22 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-03 14:27:22 +0000 |
commit | 5d63998add4e6e3a665df7cc53680ce1774d577e (patch) | |
tree | 3ac60b17b5a5d9eb5de2187416d82030d50eaa30 /sca-java-2.x/trunk/modules/binding-jms-runtime | |
parent | 79bdfa6f74e26335eee54514506bd725d6a13783 (diff) |
TUSCANY-3970 Improve error handling in TransportServiceInterceptor.invoke()
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1197137 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jms-runtime')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java index 266f02b9f1..ab3392fcce 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java @@ -79,18 +79,41 @@ public class TransportServiceInterceptor extends InterceptorAsyncImpl { try { return invokeResponse(next.invoke(invokeRequest(msg))); } catch (Throwable e) { + try { + // Normally only runtime exceptions (whether thrown by the application or the runtime) + // reach this catch block. Business exceptions are handled in the normal invokeResponse path. logger.log(Level.SEVERE, "Exception invoking service '" + service.getName(), e); - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message replyJMSMsg = responseMessageProcessor.createFaultMessage(context.getJmsResponseSession(), - (Throwable)e); - msg.setBody(replyJMSMsg); - invokeResponse(msg); + + Operation operation = msg.getOperation(); + if (operation != null && !operation.isNonBlocking()) { + JMSBindingContext context = msg.getBindingContext(); + Session session = context.getJmsResponseSession(); + javax.jms.Message replyJMSMsg = responseMessageProcessor.createFaultMessage(session, e); + msg.setBody(replyJMSMsg); + invokeResponse(msg); + } + + } catch (Throwable e2) {} + // Rethrow a runtime exception so that the JMS resource adapter can rollback + // the message (if delivery is transacted) and increment the failed delivery count. + if (e instanceof Error) { + throw (Error)e; + } + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } return msg; } finally { try { - ((JMSBindingContext)msg.getBindingContext()).closeJmsResponseSession(); - if (jmsResourceFactory.isConnectionClosedAfterUse()) - jmsResourceFactory.closeResponseConnection(); + try { + ((JMSBindingContext)msg.getBindingContext()).closeJmsResponseSession(); + } catch (Throwable e) { + } + // Use the resource factory in the binding context to close the response connection, + // to ensure we use same resource factory used to close response session. + JMSResourceFactory rf = ((JMSBindingContext)msg.getBindingContext()).getJmsResourceFactory(); + if (rf.isConnectionClosedAfterUse()) + rf.closeResponseConnection(); } catch (JMSException e) { } } |