cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [1/2] cxf git commit: Move getting exchange into a method
Date Wed, 15 Mar 2017 13:03:53 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes eab4d83fb -> ca50baa53


Move getting exchange into a method


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

Branch: refs/heads/3.1.x-fixes
Commit: ca50baa536422da01e513580c06fd5dcdf362f4c
Parents: 6937ea6
Author: Christian Schneider <chris@die-schneider.net>
Authored: Wed Mar 15 10:48:57 2017 +0100
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Wed Mar 15 14:03:40 2017 +0100

----------------------------------------------------------------------
 .../apache/cxf/transport/jms/JMSConduit.java    | 42 +++++++++++++-------
 1 file changed, 27 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ca50baa5/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
index 8576149..8b5da16 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
@@ -364,31 +364,43 @@ public class JMSConduit extends AbstractConduit implements JMSExchangeSender,
Me
             String correlationId = jmsMessage.getJMSCorrelationID();
             LOG.log(Level.FINE, "Received reply message with correlation id " + correlationId);
 
-            // Try to correlate the incoming message with some timeout as it may have been
-            // added to the map after the message was sent
-            int count = 0;
-            Exchange exchange = null;
-            while (exchange == null && count < 100) {
-                exchange = correlationMap.remove(correlationId);
-                if (exchange == null) {
-                    Thread.sleep(1);
-                }
-                count++;
-            }
+            Exchange exchange = getExchange(correlationId);
             if (exchange == null) {
                 LOG.log(Level.WARNING, "Could not correlate message with correlationId "
+ correlationId);
-                return;
+            } else {
+                processReplyMessage(exchange, jmsMessage);
             }
-            processReplyMessage(exchange, jmsMessage);
         } catch (JMSException e) {
             throw JMSUtil.convertJmsException(e);
-        } catch (InterruptedException e) {
-            throw new RuntimeException("Interrupted while correlating", e);
         }
 
     }
 
     /**
+     *  Try to correlate the incoming message with some timeout as it may have been
+     *  added to the map after the message was sent
+     *  
+     * @param correlationId
+     * @return exchange for correlationId or null if none was found
+     */
+    private Exchange getExchange(String correlationId) {
+        int count = 0;
+        Exchange exchange = null;
+        while (exchange == null && count < 100) {
+            exchange = correlationMap.remove(correlationId);
+            if (exchange == null) {
+                try {
+                    Thread.sleep(1);
+                } catch (InterruptedException e) {
+                    throw new RuntimeException("Interrupted while correlating", e);
+                }
+            }
+            count++;
+        }
+        return exchange;
+    }
+
+    /**
      * Process the reply message
      * @throws JMSException 
      */


Mime
View raw message