Rajith Attapattu wrote:
As part of the spec we need to throw
javax.jms.InvalidDestinationExceptionis the name supplied in the
unsubscribe method is not valid.
So in order to detect that

[...]

I prefer the first approach as we also need to throw an exception if this
topic (queue in topic exchange) has active consumers bound to it.
Here is the method in question. (I have also cut/paste the section from the
java doc)

public void unsubscribe(String name) throws JMSException
   {
       checkNotClosed();

       //send a queue.delete for the subscription
       String queue = _connection.getClientID() + ":" + name;
       AMQFrame frame = QueueDeleteBody.createAMQFrame(_channelId, 0,
queue, false, false, true);
       _connection.getProtocolHandler().writeFrame(frame);
   }

You can use the 'ifUnused' flag (the first boolean field, occurring after queue) to prevent deletion if there are consumers active. However, as with all errors in AMQP, this results in the channel being closed. The same would happen if the queue name does not exist.

To avoid the pain of having to recreate all the state of the current channel, it might be better to have a separate channel for this purpose.

The java broker will send the correct channel exception for an unknown queue but does not yet do so for the ifUnused (or ifEmpty) flags (queues are also removed from store regardless of these flags). The c++ broker does currently support these flags and there are tests in the python test suite for this.

Reply via email to