0

In a question and response here:

ActiveMQ Producer Multiple Queues One Session

The topic of a single producer sending messages to more them one destination is covered with a solution in Java.

Can the same thing in CPP/CMS be done?

I've tried to replicate that code using cms/activemq API but when I try to send a message to a different queue(destination), I receive error messages stating the producer can only send to the old destination.

Without writing the exact code here is the flow...

  • Create new Factory
  • Set broker URI
  • Create Connection
  • Connection start
  • Create Session
  • Create MessageProducer with a temporary queue
  • Create a new queue
  • Use session to create message
  • MessageProducer send using new queue and message
ItsGarand
  • 1
  • 1

1 Answers1

0

It is unclear what you code has done since you didn't include it but given the minimal input my guess is that you are creating a fixed destination producer by calling session->createProducer with some destination (sounds like a temp queue). This creates a producer married to that destination for life and calling the send methods that take a destination are required to throw. If you want to pool a producer and send to many different addresses then you need to create it with a NULL destination.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • Thanks for the reply Tim. This indeed was the case, The solution is to create a producer with a null destination per your answer above. – ItsGarand Oct 21 '19 at 12:59
  • To follow on with this, you can specify a queue/topic for a producer to write to as part of the send arguments, but it seems there is no analog for the consumer/receive or have I just missed it? – ItsGarand Oct 21 '19 at 15:24
  • That wouldn't make sense for a consumer, they subscribe to a target address so if you need more subscriptions just create more. Think the question is now answered, please tag it so others know the solution. – Tim Bish Oct 22 '19 at 12:57