camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] camel git commit: CAMEL-8204 Added the putIfAbsent method to avoid overriding the old key value as Claus suggested
Date Mon, 12 Jan 2015 02:19:11 GMT
CAMEL-8204 Added the putIfAbsent method to avoid overriding the old key value as Claus suggested


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

Branch: refs/heads/camel-2.13.x
Commit: 415604c053e4e8d435df2b18c7fe72620b4c13c7
Parents: 1e71183
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jan 11 14:04:24 2015 +0100
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Mon Jan 12 10:18:53 2015 +0800

----------------------------------------------------------------------
 .../jms/reply/CorrelationTimeoutMap.java        | 25 ++++++++++++++++++++
 .../jms/reply/ReplyManagerSupport.java          |  6 ++---
 2 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/415604c0/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/CorrelationTimeoutMap.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/CorrelationTimeoutMap.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/CorrelationTimeoutMap.java
index d72c8d0..e0e6731 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/CorrelationTimeoutMap.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/CorrelationTimeoutMap.java
@@ -91,6 +91,31 @@ public class CorrelationTimeoutMap extends DefaultTimeoutMap<String,
ReplyHandle
     }
 
     @Override
+    public ReplyHandler putIfAbsent(String key, ReplyHandler value, long timeoutMillis) {
+        try {
+            if (listener != null) {
+                listener.onPut(key);
+            }
+        } catch (Throwable e) {
+            // ignore
+        }
+
+        ReplyHandler result;
+        if (timeoutMillis <= 0) {
+            // no timeout (must use Integer.MAX_VALUE)
+            result = super.putIfAbsent(key, value, Integer.MAX_VALUE);
+        } else {
+            result = super.putIfAbsent(key, value, timeoutMillis);
+        }
+        if (result == null) {
+            log.trace("Added correlationID: {} to timeout after: {} millis", key, timeoutMillis);
+        } else {
+            log.trace("Duplicate correlationID: {} detected", key);
+        }
+        return result;
+    }
+
+    @Override
     public ReplyHandler remove(String key) {
         try {
             if (listener != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/415604c0/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
index 30e5919..83a7729 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java
@@ -142,13 +142,13 @@ public abstract class ReplyManagerSupport extends ServiceSupport implements
Repl
                 if (timeout) {
                     // timeout occurred do a WARN log so its easier to spot in the logs
                     if (log.isWarnEnabled()) {
-                        log.warn("Timeout occurred after {} millis waiting for reply message
with correlationID [{}]."
+                        log.warn("Timeout occurred after {} millis waiting for reply message
with correlationID [{}] on destination {}."
                                 + " Setting ExchangeTimedOutException on {} and continue
routing.",
-                                new Object[]{holder.getRequestTimeout(), holder.getCorrelationId(),
ExchangeHelper.logIds(exchange)});
+                                new Object[]{holder.getRequestTimeout(), holder.getCorrelationId(),
replyTo, ExchangeHelper.logIds(exchange)});
                     }
 
                     // no response, so lets set a timed out exception
-                    String msg = "reply message with correlationID: " + holder.getCorrelationId()
+ " not received";
+                    String msg = "reply message with correlationID: " + holder.getCorrelationId()
+ " not received on destination: " + replyTo;
                     exchange.setException(new ExchangeTimedOutException(exchange, holder.getRequestTimeout(),
msg));
                 } else {
                     JmsMessage response = new JmsMessage(message, endpoint.getBinding());


Mime
View raw message