Non-Exclusive Queue using AMQP
Hi, can it be possible to create non-exclusive queue using amqp in solace ?
I am exploring Apache Qpid JMS 2.0 over AMQP 1.0
I checked solace-samples-amqp-qpid-jms2/QueueConsumer.java at master · SolaceSamples/solace-samples-amqp-qpid-jms2 (github.com) and it creates an exclusive queue and connects the consumer to the queue. I am trying to check if we can create an non-exclusive queue as well.
Best Answer
-
Hi, I'm not familiar with this JMS library, however I would expect the behaviour to be the same as with the Solace JMS library which we would generally recommend to use with the Solace PubSub+ broker. You can access the Solace JMS library here.
Firstly, the createQueue method in JMS is very misleading, and doesn't do what you might think, from the JMS Spec:
Queue createQueue(String queueName) Creates a Queue object which encapsulates a specified provider-specific queue name. The use of provider-specific queue names in an application may render the application non-portable. Portable applications are recommended to not use this method but instead look up an administratively-defined Queue object using JNDI. Note that this method simply creates an object that encapsulates the name of a queue. It does not create the physical queue in the JMS provider. JMS does not provide a method to create the physical queue, since this would be specific to a given JMS provider. Creating a physical queue is provider-specific and is typically an administrative task performed by an administrator, though some providers may create them automatically when needed. The one exception to this is the creation of a temporary queue, which is done using the createTemporaryQueue method.
So if the physical queue has previously been created on the Solace broker, and it has been created with the non-exclusive access type, then using the JMS createQueue method will enable your client application to bind to this queue and use it as a non-exclusive queue.
If, however, the physical queue does not already exist then, the default behaviour is that, using the createQueue method will return an "Unknown Queue" error back to the client.
Having said that, Solace PubSub+ does have a feature to dynamically create endpoints if they don't already exist, which can be enabled for JMS in the ConnectionFactory settings, as described here.
When this is enabled, and a JMS client application uses the createQueue method for a queue that doesn't already exist, a default queue will be dynamically provisioned on the Solace broker. By default a queue's access type is exclusive, in order for a dynamically created queue to be a non-exclusive queue you can setup an endpoint template. A template allows dynamically created endpoints to inherit custom attributes, as described here. Create a queue template with a filter that matches your queue name and specify a non-exclusive access type. You will also need to enable the queue template in the client profile configuration for the client username used by your JMS client. Now when your queue is created dynamically it will have the non-exclusive access type!
HTH
Richard
3
Answers
-
Hi, I'm not familiar with this JMS library, however I would expect the behaviour to be the same as with the Solace JMS library which we would generally recommend to use with the Solace PubSub+ broker. You can access the Solace JMS library here.
Firstly, the createQueue method in JMS is very misleading, and doesn't do what you might think, from the JMS Spec:
Queue createQueue(String queueName) Creates a Queue object which encapsulates a specified provider-specific queue name. The use of provider-specific queue names in an application may render the application non-portable. Portable applications are recommended to not use this method but instead look up an administratively-defined Queue object using JNDI. Note that this method simply creates an object that encapsulates the name of a queue. It does not create the physical queue in the JMS provider. JMS does not provide a method to create the physical queue, since this would be specific to a given JMS provider. Creating a physical queue is provider-specific and is typically an administrative task performed by an administrator, though some providers may create them automatically when needed. The one exception to this is the creation of a temporary queue, which is done using the createTemporaryQueue method.
So if the physical queue has previously been created on the Solace broker, and it has been created with the non-exclusive access type, then using the JMS createQueue method will enable your client application to bind to this queue and use it as a non-exclusive queue.
If, however, the physical queue does not already exist then, the default behaviour is that, using the createQueue method will return an "Unknown Queue" error back to the client.
Having said that, Solace PubSub+ does have a feature to dynamically create endpoints if they don't already exist, which can be enabled for JMS in the ConnectionFactory settings, as described here.
When this is enabled, and a JMS client application uses the createQueue method for a queue that doesn't already exist, a default queue will be dynamically provisioned on the Solace broker. By default a queue's access type is exclusive, in order for a dynamically created queue to be a non-exclusive queue you can setup an endpoint template. A template allows dynamically created endpoints to inherit custom attributes, as described here. Create a queue template with a filter that matches your queue name and specify a non-exclusive access type. You will also need to enable the queue template in the client profile configuration for the client username used by your JMS client. Now when your queue is created dynamically it will have the non-exclusive access type!
HTH
Richard
3