activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franz1981 <...@git.apache.org>
Subject [GitHub] activemq-artemis pull request #2427: ARTEMIS-2170 Optimized CoreMessage's ch...
Date Fri, 16 Nov 2018 07:40:29 GMT
Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2427#discussion_r234112554
  
    --- Diff: artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java
---
    @@ -52,6 +52,62 @@
      *  consumers */
     public class CoreMessage extends RefCountMessage implements ICoreMessage {
     
    +   private static final class CoreTypedProperties extends TypedProperties {
    +
    +      // We use properties to establish routing context on clustering.
    +      // However if the client resends the message after receiving, it needs to be removed
    +      private static final Predicate<SimpleString> INTERNAL_PROPERTY_NAMES_CLEANUP_FILTER
=
    +         name -> (name.startsWith(Message.HDR_ROUTE_TO_IDS) && !name.equals(Message.HDR_ROUTE_TO_IDS))
||
    +            (name.startsWith(Message.HDR_ROUTE_TO_ACK_IDS) && !name.equals(Message.HDR_ROUTE_TO_ACK_IDS));
    +      private static final SimpleString AMQ_PROPNAME = new SimpleString("_AMQ_");
    +      private boolean internalProperties;
    +
    +      CoreTypedProperties() {
    +         super();
    +         internalProperties = false;
    +      }
    +
    +      private CoreTypedProperties(TypedProperties other) {
    +         super(other);
    +         if (other instanceof CoreTypedProperties) {
    +            internalProperties = ((CoreTypedProperties) other).internalProperties;
    +         } else {
    +            internalProperties = other.containsProperty(name -> name.startsWith(AMQ_PROPNAME));
    +         }
    +      }
    +
    +      @Override
    +      protected synchronized void doPutValue(SimpleString key, TypedProperties.PropertyValue
value) {
    +         if (!internalProperties && key.startsWith(AMQ_PROPNAME)) {
    +            internalProperties = true;
    +         }
    +         super.doPutValue(key, value);
    +      }
    +
    +      public synchronized boolean cleanupInternalProperties() {
    +         if (!internalProperties) {
    +            return false;
    +         }
    +         return removeProperty(INTERNAL_PROPERTY_NAMES_CLEANUP_FILTER);
    +      }
    +
    +      public static boolean cleanupInternalProperties(TypedProperties typedProperties)
{
    +         if (typedProperties == null) {
    +            return false;
    +         }
    +         if (typedProperties instanceof CoreTypedProperties) {
    +            return ((CoreTypedProperties) typedProperties).cleanupInternalProperties();
    +         }
    +         return typedProperties.removeProperty(INTERNAL_PROPERTY_NAMES_CLEANUP_FILTER);
    +      }
    +
    +      public static CoreTypedProperties copyOf(TypedProperties typedProperties) {
    +         synchronized (typedProperties) {
    --- End diff --
    
    Nice: I have removed subclass of `TypedProperties` and cleaned up the code: it seems much
better now. The only thing that bother me is that I would like to avoid at all to perform
that `cleanupInternalProperties`, given that most of time it won't find anything; i just need
to understand what's its purpose and how to know in advance when do it is a waste of time.


---

Mime
View raw message