0

A customer wants to flush the queue in one go. However, neither of the batch options seems to be available in Java, so they insist on deleting the queue altogether.

The question is, how do I detect that a queue is no longer there? Is there some kind of a hook? Because my listener will simply be silent and do nothing.

(The queue is created when the worker role starts if it doesn't exist yet, so generally restarting the queue would work. The only problem is, there are many instances so it's a bit problematic to restart it.)

Vadim Berman
  • 1,932
  • 1
  • 20
  • 39

1 Answers1

0

NamespaceManager.QueueExists should get the job done for you.

ScottS
  • 8,455
  • 3
  • 30
  • 50
  • I know that, but what is going to call it? Currently all the messages are received via _queueClient.OnMessage((receivedMessage) => { ... }); – Vadim Berman Jan 22 '15 at 06:44
  • @VadimBerman if they insist on deleting the queue, you are just going to have to poll for it's existence occasionally. I'm inclined to look for a solution that doesn't involve deleting and recreating a queue. I don't know what java library they are using, but both Receive and Delete and Peek Lock are acccessible over the REST API, so it's not hard to access the functionality that they need. – ScottS Jan 22 '15 at 06:53
  • Well, I agree, but they want to clear it in one go, and they have a Java client, so PrefetchCount and batch clearing doesn't work. Nevertheless, where am I going to poll it from? I don't want to set up a timer. This is the only reason I'm asking. – Vadim Berman Jan 22 '15 at 06:55
  • I must be misunderstanding something about how/why your client wants to delete the queue, I don't see how deleting the queue and receiving all messages in a single operation are related. I don't think it is even possible to guarantee that you receive all messages in a single batch. When your process starts, you can spawn a task to continuously check for the queue and recreate as needed, sleeping between. Your queue producers are going to run into problems when the queue doesn't exist. I guess you could catch that exception and recreate the queue as needed. It all sounds very messy to me. – ScottS Jan 22 '15 at 07:06
  • The customer submits the queues, my worker roles are processing them. Hence the `OnMessage` snippet. I know I can test it continuously, but I want something more intelligent, like an event or a hook I could use, like I asked in the original question. But it sounds like the easiest way is just to restart everything from outside. – Vadim Berman Jan 22 '15 at 07:12