amqpcpp icon indicating copy to clipboard operation
amqpcpp copied to clipboard

Allow declaring a queue without specifying the name

Open AntAgna opened this issue 3 years ago • 2 comments

Code examples on https://rabbitmq.com for RPC recommend declaring a queue without a name to serve as channel for the response from the RPC server. When we do this, the RabbitMQ server generates a random queue name for us.

See example here : https://www.rabbitmq.com/tutorials/tutorial-six-dotnet.html Relevant code in the RpcClient class: replyQueueName = channel.QueueDeclare().QueueName; We can see that the queue is declared without a name and then the code use the automatically generated name in the messages sent to the RPC server. The RPC server then sends the answer to this queue.

When trying to do the same with amqpcpp, declaring the queue fails with this exception : "the queue must to have the name".

So I think amqpcpp should allow doing the same thing :

  • Accept an empty name when declaring a queue
  • Use the name provided by RabbitMQ in that case

AntAgna avatar Aug 06 '21 14:08 AntAgna

You can just remove the check – works fine, at least on my machine: https://github.com/akalend/amqpcpp/pull/78/commits/8365a677d5dca7977ac5728ae09569e08a091141

That "fix" is included in PR #78, together with other improvements I've found useful. So you may want to try and use my develop branch.

reunanen avatar Aug 06 '21 14:08 reunanen

It turns out being able to disable SSL is quite useful for me. So I will be using you develop branch.

AntAgna avatar Aug 09 '21 18:08 AntAgna