You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/12/24 12:35:48 UTC

[2/2] camel git commit: CAMEL-8173 Polished the code of TimeoutInflightRepository

CAMEL-8173 Polished the code of TimeoutInflightRepository


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

Branch: refs/heads/master
Commit: 49f937d79cb507d23a33a3d41c6f8809695bde31
Parents: 28b49e8
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Dec 24 18:54:53 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Dec 24 19:35:14 2014 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/impl/TimeoutInflightRepository.java | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/49f937d7/camel-core/src/main/java/org/apache/camel/impl/TimeoutInflightRepository.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/TimeoutInflightRepository.java b/camel-core/src/main/java/org/apache/camel/impl/TimeoutInflightRepository.java
index b3ad72e..64a58c4 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/TimeoutInflightRepository.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/TimeoutInflightRepository.java
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
 public class TimeoutInflightRepository extends ServiceSupport implements InflightRepository {
     private static final Logger LOG = LoggerFactory.getLogger(TimeoutInflightRepository.class);
     private static final String INFLIGHT_TIME_STAMP = "CamelInflightTimeStamp";
+    private static final String TIMEOUT_EXCHANGE_PROCESSED = "CamelTimeoutExchangeProcessed";
     private ExchangeFormatter exchangeFormatter;
     private final Map<String, Exchange> inflightExchanges = new ConcurrentHashMap<String, Exchange>();
     private long waitTime = 60 * 1000;
@@ -85,7 +86,7 @@ public class TimeoutInflightRepository extends ServiceSupport implements Infligh
 
     @Override
     public void remove(Exchange exchange) {
-        exchange.removeProperties(INFLIGHT_TIME_STAMP);
+        exchange.removeProperty(INFLIGHT_TIME_STAMP);
         inflightExchanges.remove(exchange.getExchangeId());
     }
 
@@ -185,9 +186,11 @@ public class TimeoutInflightRepository extends ServiceSupport implements Infligh
                 for (Exchange exchange : inflightExchanges.values()) {
                     // check if the exchange is timeout
                     long timeStamp = exchange.getProperty(INFLIGHT_TIME_STAMP, Long.class);
+                    Boolean processed = exchange.getProperty(TIMEOUT_EXCHANGE_PROCESSED, Boolean.FALSE, Boolean.class);
                     long processingTime = System.currentTimeMillis() - timeStamp;
-                    if (processingTime > timeout) {
+                    if (!processed && processingTime > timeout) {
                         processTimeoutExchange(exchange, processingTime);
+                        exchange.setProperty(TIMEOUT_EXCHANGE_PROCESSED, Boolean.TRUE);
                     }
                 }
                 try {