diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java index 7d29a33442..ddb8a3b7c4 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/Message.java @@ -93,7 +93,7 @@ public interface Message { SimpleString HDR_ACTUAL_EXPIRY_TIME = new SimpleString("_AMQ_ACTUAL_EXPIRY"); /** - * The original address of a message when a message is transferred through DLQ or expiry + * The original address of a message when a message is diverted or transferred through DLQ or expiry */ SimpleString HDR_ORIGINAL_ADDRESS = new SimpleString("_AMQ_ORIG_ADDRESS"); @@ -103,7 +103,7 @@ public interface Message { SimpleString HDR_ORIGINAL_QUEUE = new SimpleString("_AMQ_ORIG_QUEUE"); /** - * The original message ID before th emessage was transferred. + * The original message ID before the message was transferred. */ SimpleString HDR_ORIG_MESSAGE_ID = new SimpleString("_AMQ_ORIG_MESSAGE_ID"); diff --git a/docs/user-manual/en/diverts.md b/docs/user-manual/en/diverts.md index 86b1b80109..4c71b341df 100644 --- a/docs/user-manual/en/diverts.md +++ b/docs/user-manual/en/diverts.md @@ -44,6 +44,13 @@ geographically distributed servers, creating your global messaging mesh. Diverts are defined as xml in the `broker.xml` file at the `core` attribute level. There can be zero or more diverts in the file. +Diverted message gets a new message ID, and its address is set to a forward +address. To access original values, use message properties: original destination +is stored in a String property `_AMQ_ORIG_ADDRESS` (`Message.HDR_ORIGINAL_ADDRESS` +constant from the Core API), and the original message ID in a Long property +`_AMQ_ORIG_MESSAGE_ID` (`Message.HDR_ORIG_MESSAGE_ID` constant from the +Core API). + Please see the examples for a full working example showing you how to configure and use diverts. diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java index 9f60b30d52..3d7100464e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java @@ -104,6 +104,10 @@ public class DivertTest extends ActiveMQTestBase { Assert.assertEquals(i, message.getObjectProperty(propKey)); + Assert.assertEquals("forwardAddress", message.getAddress()); + + Assert.assertEquals("testAddress", message.getStringProperty(Message.HDR_ORIGINAL_ADDRESS)); + message.acknowledge(); } @@ -116,6 +120,8 @@ public class DivertTest extends ActiveMQTestBase { Assert.assertEquals(i, message.getObjectProperty(propKey)); + Assert.assertEquals("testAddress", message.getAddress()); + message.acknowledge(); } @@ -590,6 +596,10 @@ public class DivertTest extends ActiveMQTestBase { Assert.assertEquals(i, message.getObjectProperty(propKey)); + Assert.assertEquals("forwardAddress", message.getAddress()); + + Assert.assertEquals("testAddress", message.getStringProperty(Message.HDR_ORIGINAL_ADDRESS)); + message.acknowledge(); }