cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject [cxf] branch master updated: [CXF-8105]introduce a property for JMS transport client to decide reset JMS connection or not when client timeout
Date Tue, 03 Sep 2019 19:10:26 GMT
This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new e222c38  [CXF-8105]introduce a property for JMS transport client to decide reset
JMS connection or not when client timeout
e222c38 is described below

commit e222c38125bb193cd2ea7da000833c99191cfb55
Author: Freeman Fang <freeman.fang@gmail.com>
AuthorDate: Tue Sep 3 15:10:14 2019 -0400

    [CXF-8105]introduce a property for JMS transport client to decide reset JMS connection
or not when client timeout
---
 .../src/main/java/org/apache/cxf/transport/jms/JMSConduit.java |  8 +++++++-
 .../java/org/apache/cxf/transport/jms/JMSConfiguration.java    |  9 +++++++++
 .../java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java     |  9 +++++++++
 .../main/java/org/apache/cxf/transport/jms/util/JMSUtil.java   | 10 ++++++++--
 4 files changed, 33 insertions(+), 3 deletions(-)

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 7b60ae3..25cffca 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
@@ -275,6 +275,7 @@ public class JMSConduit extends AbstractConduit implements JMSExchangeSender,
Me
 
             try {
                 if (useSyncReceive) {
+                    exchange.put(JMSUtil.JMS_IGNORE_TIMEOUT, this.jmsConfig.isIgnoreTimeoutException());
                     javax.jms.Message replyMessage = JMSUtil.receive(session, replyDestination,
                                                                      correlationId,
                                                                      jmsConfig.getReceiveTimeout(),
@@ -288,8 +289,13 @@ public class JMSConduit extends AbstractConduit implements JMSExchangeSender,
Me
                         throw new JMSException("Interrupted while correlating " +  e.getMessage());
                     }
                     if (!Boolean.TRUE.equals(exchange.get(CORRELATED))) {
-                        throw new JMSException("Timeout receiving message with correlationId
"
+                        if (this.jmsConfig.isIgnoreTimeoutException()) {
+                            throw new RuntimeException("Timeout receiving message with correlationId
"
+                                + correlationId);
+                        } else {
+                            throw new JMSException("Timeout receiving message with correlationId
"
                                                    + correlationId);
+                        }
                     }
 
                 }
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 bead3e7..31a53b7 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
@@ -49,6 +49,7 @@ public class JMSConfiguration {
     private boolean pubSubNoLocal;
     private Long clientReceiveTimeout = 60000L;
     private Long serverReceiveTimeout;
+    private boolean ignoreTimeoutException;
     private boolean explicitQosEnabled;
     private int deliveryMode = Message.DEFAULT_DELIVERY_MODE;
     private int priority = Message.DEFAULT_PRIORITY;
@@ -522,4 +523,12 @@ public class JMSConfiguration {
         this.retryInterval = retryInterval;
     }
 
+    public boolean isIgnoreTimeoutException() {
+        return ignoreTimeoutException;
+    }
+
+    public void setIgnoreTimeoutException(boolean ignoreTimeoutException) {
+        this.ignoreTimeoutException = ignoreTimeoutException;
+    }
+
 }
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
index 89257d8..6ca3567 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/uri/JMSEndpoint.java
@@ -89,6 +89,7 @@ public class JMSEndpoint {
     private String messageSelector;
     private int retryInterval = 5000;
     private boolean oneSessionPerConnection;
+    private boolean ignoreTimeoutException;
 
     /**
      * @param uri
@@ -512,4 +513,12 @@ public class JMSEndpoint {
         this.oneSessionPerConnection = oneSessionPerConnection;
     }
 
+    public boolean isIgnoreTimeoutException() {
+        return ignoreTimeoutException;
+    }
+
+    public void setIgnoreTimeoutException(boolean ignoreTimeoutException) {
+        this.ignoreTimeoutException = ignoreTimeoutException;
+    }
+
 }
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
index 6c4472d..6f0d97e 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
@@ -36,7 +36,8 @@ import org.apache.cxf.transport.jms.JMSConstants;
 
 public final class JMSUtil {
     
-    public static final String JMS_MESSAGE_CONSUMER = "jms_message_consumer"; 
+    public static final String JMS_MESSAGE_CONSUMER = "jms_message_consumer";
+    public static final String JMS_IGNORE_TIMEOUT = "jms_ignore_timeout";
     private static final char[] CORRELATTION_ID_PADDING = {
         '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'
     };
@@ -79,8 +80,13 @@ public final class JMSUtil {
             }
             javax.jms.Message replyMessage = consumer.receive(receiveTimeout);
             if (replyMessage == null) {
-                throw new RuntimeException("Timeout receiving message with correlationId
"
+                if ((boolean)exchange.get(JMSUtil.JMS_IGNORE_TIMEOUT)) {
+                    throw new RuntimeException("Timeout receiving message with correlationId
"
                                            + correlationId);
+                } else {
+                    throw new JMSException("Timeout receiving message with correlationId
"
+                        + correlationId);
+                }
             }
             return replyMessage;
         } catch (JMSException e) {


Mime
View raw message