0
votes

I have got 10 queues on activemq server. I have producer which want to push messages on one of the queue (the producer will select the queue randomly run time to put message on queue), how can I pass destination name in createProducer method. I understand that I need to pass an object of type Destination. the producer would know the queues name on the server. Is it possible to pass (or convert) a string to Destination object type and pass that to createproducer method.

Thanks

1

1 Answers

1
votes

If I understand your problem correctly;

If you're running Java and have a valid session, you could use Session.createQueue();

// Create a Destination using the queue name
Destination destination = session.createQueue("queue name");

// Create a MessageProducer from the Session to the Queue
MessageProducer producer = session.createProducer(destination);

Here is a complete example of doing this at the Apache site.