0

When I try in my c# app to change TTL for the queue I catch an exception and channel is closed. How to check if queue already exists to prevent this situation? i.e. if queue do not exist I create it with TTL and other parameters else I do not try to create it.

ZedZip
  • 5,794
  • 15
  • 66
  • 119
  • Seems to be duplicate. Please, check this out: https://stackoverflow.com/questions/3457305/how-can-i-check-whether-a-rabbitmq-message-queue-exists-or-not – Maciej Grala Nov 28 '21 at 09:16
  • But, queues are created implicitly; they aren't a thing you need to check and create if not exists, you just try and use a particular one and if it doesn't exist it is created and used. If it does exist it is used – Caius Jard Nov 28 '21 at 09:49
  • You are right, but I set TTL for the queue. And if it already exists the channel is closed. i.e. in this function when exception the channel is closed. public static bool QueExists(IModel channel, string QueName) { bool b = false; try { var xx = channel.QueueDeclarePassive(QueName); b = true; } catch (Exception x) { Console.WriteLine("Queue {0} does not exist", x.Message); } return b; } – ZedZip Nov 28 '21 at 10:02
  • @CaiusJard Yes, but I create the queue with TTL and in this my function in case of exception the channel closed(!) and I cannot continue to work with queue – ZedZip Nov 28 '21 at 11:02

0 Answers0