Skip to content
Advertisement

Spring and JMS DynamicDestinationResolution

I am using the latest Spring 4 and ActiveMQ to put JMS messages on a queue. Using the JMSTemplate, I have a default queue, and the sample code I have lets me put a message on the default queue with no issues. There is also a sample code that lets me put a message on a Destination … this is where I am hung up.

original method:

JavaScript

If I have a Destination, I can pass that in and it should work, but I haven’t tried it yet. What I really want to do is pass in a string for a name or a topic.

Here is what I’d like:

JavaScript

If the queue or topic exist, return that Destination, otherwise return null.

We are not wanting temporary queues or topics, and we are not creating new queues or topics on the fly. We are also not using JNDI within this Spring application. We use the ActiveMQ web-admin tool to create our topics or queues.

So, I was looking for an example of a method like I described. I have scoured the net before I came here, and I looked here first before I posted this question. If someone can refer me to some documentation or a site that has a code snippet for this, that would be great.

Thanks for the help!

Advertisement

Answer

Turns out I didn’t need to do anything. Here is how my activemq is defined in the context xml file:

JavaScript

When I was looking at the different methods under ‘jmsTemplate’ I didn’t realize there was a .send method with String for a destination name. I knew there was a send method with Destination as the first parameter. So, there was really no issue. This method works fine.

JavaScript

Hope this helps someone out.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement