diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java index 84e319cd2c..5e80c7e8d3 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java @@ -252,7 +252,7 @@ public abstract class AMQPMessage extends RefCountMessage implements org.apache. this.encodedDeliveryAnnotationsSize = copy.encodedDeliveryAnnotationsSize; this.deliveryAnnotations = copy.deliveryAnnotations == null ? null : new DeliveryAnnotations(copy.deliveryAnnotations.getValue()); this.messageAnnotationsPosition = copy.messageAnnotationsPosition; - this.messageAnnotations = copy.messageAnnotations == null ? null : new MessageAnnotations(copy.messageAnnotations.getValue()); + this.messageAnnotations = copyAnnotations(copy.messageAnnotations); this.propertiesPosition = copy.propertiesPosition; this.properties = copy.properties == null ? null : new Properties(copy.properties); this.applicationPropertiesPosition = copy.applicationPropertiesPosition; @@ -261,6 +261,20 @@ public abstract class AMQPMessage extends RefCountMessage implements org.apache. this.messageDataScanned = copy.messageDataScanned; } + private static MessageAnnotations copyAnnotations(MessageAnnotations messageAnnotations) { + if (messageAnnotations == null) { + return null; + } + HashMap newAnnotation = new HashMap(); + messageAnnotations.getValue().forEach((a, b) -> { + // These properties should not be copied when re-routing the messages + if (!a.toString().startsWith("x-opt-ORIG") && !a.toString().equals("x-opt-routing-type")) { + newAnnotation.put(a, b); + } + }); + return new MessageAnnotations(newAnnotation); + } + protected AMQPMessage(long messageFormat) { this.messageFormat = messageFormat; this.coreMessageObjectPools = null;