Search code examples
javaapache-camelactivemq-classicwildcardconsumer

Differentiate which queue was called when using wildcards in apache camel


In my application, I am using wildcards in apache camel and I have defined route builder like this:

from("activemq:queue:*.processQueue").bean(beanOne,"someMethod");

While sending the message I will be sending message to "{uniqueID}.processQueue" queue so I need to get that uniqueId inside someMethod of beanOne.


Solution

  • The full queue path is in the In message's JMSDestination header ( for example the JMSDestination is queue://test1.processQueue). You can use string manipulation functions to get the required uniqueId.

    Example (uniqueId will be test1):

    @Handler
    public void someMethod(@Header("JMSDestination") String jmsDestination) {
        String uniqueId = jmsDestination.substring("queue://".length(), jmsDestination.indexOf(".processQueue"));
    }