[prev in list] [next in list] [prev in thread] [next in thread] 

List:       activemq-commits
Subject:    [activemq-artemis] branch master updated: ARTEMIS-2205 Fixing Divert Example
From:       clebertsuconic () apache ! org
Date:       2019-01-30 20:38:44
Message-ID: 154888072459.31743.17634986764894414538 () gitbox ! apache ! org
[Download RAW message or body]

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new c0edb88  ARTEMIS-2205 Fixing Divert Example
     new 40704c8  This closes #2531
c0edb88 is described below

commit c0edb88747c13abd60efbea1bff101f488d03ac1
Author: Clebert Suconic <clebertsuconic@apache.org>
AuthorDate: Wed Jan 30 13:04:21 2019 -0500

    ARTEMIS-2205 Fixing Divert Example
    
    This is simply fixing the example under examples/features/standard/divert
    Other tests are passing.
    No additional tests are needed as the example on this case acts like a test.
---
 .../artemis/core/postoffice/impl/BindingsImpl.java      | 16 +++++++++++-----
 .../artemis/core/postoffice/impl/PostOfficeImpl.java    |  2 ++
 .../activemq/artemis/core/server/RoutingContext.java    |  4 ++--
 .../activemq/artemis/core/server/impl/DivertImpl.java   |  4 +++-
 .../artemis/core/server/impl/RoutingContextImpl.java    | 17 ++++++++++++++---
 5 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java \
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
 index 1b7b79f..c3bf31a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
                
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java
 @@ -282,6 +282,12 @@ public final class BindingsImpl implements Bindings {
    private void route(final Message message,
                       final RoutingContext context,
                       final boolean groupRouting) throws Exception {
+      boolean reusableContext = context.isReusable(message, version.get());
+
+      if (!reusableContext) {
+         context.clear();
+      }
+
       /* This is a special treatment for scaled-down messages involving SnF queues.
        * See org.apache.activemq.artemis.core.server.impl.ScaleDownHandler.scaleDownMessages() \
                for the logic that sends messages with this property
        */
@@ -310,6 +316,7 @@ public final class BindingsImpl implements Bindings {
             binding.getBindable().route(message, context);
             routed = true;
          }
+         context.setReusable(false);
       }
       if (!routed) {
          // Remove the ids now, in order to avoid double check
@@ -319,10 +326,10 @@ public final class BindingsImpl implements Bindings {
          SimpleString groupId = message.getGroupID();
 
          if (ids != null) {
-            context.clear();
+            context.clear().setReusable(false);
             routeFromCluster(message, context, ids);
          } else if (groupingHandler != null && groupRouting && groupId != null) {
-            context.clear();
+            context.clear().setReusable(false);
             routeUsingStrictOrdering(message, context, groupingHandler, groupId, 0);
          } else if (CompositeAddress.isFullyQualified(message.getAddress())) {
             Binding theBinding = \
bindingsNameMap.get(CompositeAddress.extractQueueName(message.getAddressSimpleString()));
 @@ -331,9 +338,8 @@ public final class BindingsImpl implements Bindings {
             }
          } else {
             // in a optimization, we are reusing the previous context if everything \
                is right for it
-            // so the simpleRouting will only happen if neededk
-            if (!context.isReusable(message, version.get())) {
-               context.clear();
+            // so the simpleRouting will only happen if needed
+            if (!reusableContext) {
                simpleRouting(message, context);
             }
          }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java \
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
 index 605e43e..c552ca9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
                
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
 @@ -889,6 +889,7 @@ public class PostOfficeImpl implements PostOffice, \
NotificationListener, Binding  
       if (bindingMove != null) {
          context.clear();
+         context.setReusable(false);
          bindingMove.route(message, context);
          if (addressInfo != null) {
             addressInfo.incrementRoutedMessageCount();
@@ -899,6 +900,7 @@ public class PostOfficeImpl implements PostOffice, \
NotificationListener, Binding  addressInfo.incrementRoutedMessageCount();
          }
       } else {
+         context.setReusable(false);
          if (addressInfo != null) {
             addressInfo.incrementUnRoutedMessageCount();
          }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/RoutingContext.java \
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/RoutingContext.java
 index 151aa41..bfde7af 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/RoutingContext.java
                
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/RoutingContext.java
 @@ -40,7 +40,7 @@ public interface RoutingContext {
 
    SimpleString getPreviousAddress();
 
-   void setReusable(boolean reusable);
+   RoutingContext setReusable(boolean reusable);
 
    RoutingContext setReusable(boolean reusable, int version);
 
@@ -60,7 +60,7 @@ public interface RoutingContext {
 
    int getQueueCount();
 
-   void clear();
+   RoutingContext clear();
 
    void addQueueWithAck(SimpleString address, Queue queue);
 
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java \
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java
 index e6aa210..dce20e7 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java
                
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java
 @@ -90,6 +90,8 @@ public class DivertImpl implements Divert {
          logger.trace("Diverting message " + message + " into " + this);
       }
 
+      context.setReusable(false);
+
       Message copy = null;
 
       // Shouldn't copy if it's not routed anywhere else
@@ -127,7 +129,7 @@ public class DivertImpl implements Divert {
          copy = message;
       }
 
-      postOffice.route(copy, context.getTransaction(), false);
+      postOffice.route(copy, new \
RoutingContextImpl(context.getTransaction()).setReusable(false), false);  }
 
    @Override
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java \
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java
 index b5b36bb..e9df830 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java
                
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java
 @@ -79,8 +79,14 @@ public final class RoutingContextImpl implements RoutingContext {
    }
 
    @Override
-   public void setReusable(boolean reusable) {
+   public RoutingContext setReusable(boolean reusable) {
+      if (this.reusable != null && !this.reusable.booleanValue()) {
+         // cannot set to Reusable once it was set to false
+         return this;
+      }
+
       this.reusable = reusable;
+      return this;
    }
    @Override
    public RoutingContext setReusable(boolean reusable, int previousBindings) {
@@ -96,7 +102,7 @@ public final class RoutingContextImpl implements RoutingContext {
    }
 
    @Override
-   public void clear() {
+   public RoutingContext clear() {
       map.clear();
 
       queueCount = 0;
@@ -104,6 +110,8 @@ public final class RoutingContextImpl implements RoutingContext {
       this.version = 0;
 
       this.reusable = null;
+
+      return this;
    }
 
    @Override
@@ -147,7 +155,10 @@ public final class RoutingContextImpl implements RoutingContext \
{  
    @Override
    public boolean isReusable(Message message, int version) {
-      return isReusable() && queueCount > 0 && address.equals(previousAddress) && \
previousRoutingType == routingType && getPreviousBindingsVersion() == version; +      \
if (getPreviousBindingsVersion() != version) { +         this.reusable = false;
+      }
+      return isReusable() && queueCount > 0 && address.equals(previousAddress) && \
previousRoutingType == routingType;  }
 
    @Override


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic