To achieve this, we are using a custom JMS property that embeds the routing key to the message. Wwe e are embedding the routing key to a JMS property of the message from the andes-client side. The embedding is enabled only when the “AndesSetRoutingKey” system property is set to a non-null value (any value other than null) in the publisher client. When the mentioned system property is set, each message will have a JMS property of type string with the “JMS_ANDES_ROUTING_KEY” name, which will contain the routing key.
Configuring the publisher client
The custom JMS property should be enabled for the publisher client as shown below.
Configuring the subscriber client
The subscriber client can retrieve the JMS property in the message as shown below.
System.out.println("PROP:" + message.getStringProperty("JMS_ANDES_ROUTING_KEY"));