This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 589157ca5f ARTEMIS-4268 AMQPMessage copy constructor shouldn't copy
all message annotations
589157ca5f is described below
commit 589157ca5f7b07528e09d207282cb00a7796db67
Author: Clebert Suconic <[email protected]>
AuthorDate: Mon May 1 16:13:26 2023 -0400
ARTEMIS-4268 AMQPMessage copy constructor shouldn't copy all message
annotations
During redistribution, we should not copy all message annotations.
In particular we should not copy any of the x-opt-ORIG annotations used on
DLQ and other copies.
this was broken after f632e8104bbdae1fbf3658fec47e180784e957da
(ARTEMIS-3833 Preserve JMSCorrelationID of distributed AMQP large messages)
The change preserved too much, and as a result of that
AmqpLargeMessageRedistributionTest::testSendMessageToBroker0GetFromBroker2 is
intermittently failing.
There is no test in this commit as this is fixing
AmqpLargeMessageRedistributionTest
---
.../artemis/protocol/amqp/broker/AMQPMessage.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
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;