cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject cxf git commit: [CXF-6778] reset cached destination in case of exception
Date Wed, 19 Apr 2017 12:59:14 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5e17bc043 -> 41a97e477


[CXF-6778] reset cached destination in case of exception


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/41a97e47
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/41a97e47
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/41a97e47

Branch: refs/heads/master
Commit: 41a97e477318914fd938ef0f3d6a9f263abfa7cc
Parents: 5e17bc0
Author: Christian Schneider <chris@die-schneider.net>
Authored: Wed Apr 19 14:57:49 2017 +0200
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Wed Apr 19 14:57:49 2017 +0200

----------------------------------------------------------------------
 .../cxf/transport/jms/JMSConfiguration.java     | 27 ++++++++++++--------
 .../apache/cxf/transport/jms/JMSFactory.java    | 10 +++++++-
 2 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/41a97e47/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
index 4b1052d..8498a65 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
@@ -79,11 +79,6 @@ public class JMSConfiguration {
     private String replyToDestination;
     private volatile Destination replyToDestinationDest;
     
-    /**
-     * Session that was used to cache the replyToDestinationDest
-     */
-    private volatile Session replyDestinationSession;
-    
     private String messageType = JMSConstants.TEXT_MESSAGE_TYPE;
     private boolean pubSubDomain;
     private boolean replyPubSubDomain;
@@ -468,19 +463,29 @@ public class JMSConfiguration {
     }
 
     public Destination getReplyDestination(Session session) throws JMSException {
-        if (this.replyDestinationDest == null || this.replyDestinationSession == null) {
+        if (this.replyDestinationDest == null) {
             synchronized (this) {
-                if (this.replyDestinationDest == null || this.replyDestinationSession ==
null) {
-                    this.replyDestinationDest = replyDestination == null
-                        ? session.createTemporaryQueue()
-                        : destinationResolver.resolveDestinationName(session, replyDestination,
replyPubSubDomain);
-                    this.replyDestinationSession = session;
+                if (this.replyDestinationDest == null) {
+                    this.replyDestinationDest = getReplyDestinationInternal(session);
                 }
             }
         }
         return this.replyDestinationDest;
     }
 
+    private Destination getReplyDestinationInternal(Session session) throws JMSException
{
+        return replyDestination == null
+            ? session.createTemporaryQueue()
+            : destinationResolver.resolveDestinationName(session, replyDestination, replyPubSubDomain);
+    }
+    
+    public void resetCachedReplyDestination() {
+        synchronized (this) {
+            this.replyDestination = null;
+        }
+    }
+
+
     public Destination getTargetDestination(Session session) throws JMSException {
         return destinationResolver.resolveDestinationName(session, targetDestination, pubSubDomain);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/41a97e47/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
index 68b6173..e8ebc29 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSFactory.java
@@ -23,6 +23,7 @@ import java.util.concurrent.Executors;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
 
 import org.apache.cxf.Bus;
@@ -77,7 +78,7 @@ public final class JMSFactory {
         return correlationIdPrefix.isEmpty() ? null : "JMSCorrelationID LIKE '" + correlationIdPrefix
+ "%'";
     }
 
-    public static Connection createConnection(JMSConfiguration jmsConfig) throws JMSException
{
+    public static Connection createConnection(final JMSConfiguration jmsConfig) throws JMSException
{
         String username = jmsConfig.getUserName();
         ConnectionFactory cf = jmsConfig.getConnectionFactory();
         Connection connection = username != null
@@ -86,6 +87,13 @@ public final class JMSFactory {
         if (jmsConfig.getDurableSubscriptionClientId() != null) {
             connection.setClientID(jmsConfig.getDurableSubscriptionClientId());
         }
+        connection.setExceptionListener(new ExceptionListener() {
+            
+            @Override
+            public void onException(JMSException exception) {
+                jmsConfig.resetCachedReplyDestination();
+            }
+        });
         return connection;
     }
 


Mime
View raw message