You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by ranjanip <ra...@gmail.com> on 2013/12/05 04:28:41 UTC

How to check if a queue already exists

Hi,

I refer to the post in :
http://activemq.2283324.n4.nabble.com/How-to-send-a-textMessage-to-an-exising-queue-destination-td3481137.html

I have a different situation where I have a Java consumer and a cpp
producer. My java side is the consumer, it creates the queueA by connecting
to the broker and then the CMS  side being the producer will publish
messages to the queueA. This producer should get access to the queueA
(already created by Java consumer) and publish to it. If the queue doesnt
exist, it shouldnt publish at all. the queue creation is dynamic as the
names will be decided at runtime.

I tried using the DynamicDestinationResolver to get an access to the
existing destination, but realized that it creates a new one if it doesnt
already exist.

I saw many posts on using advisory, but couldnt find any sample usage for
the cms side. Any help on this will be greatly appreciated. Please let me
know if I should add any other info here.

Thanks,
Ranjani



--
View this message in context: http://activemq.2283324.n4.nabble.com/How-to-check-if-a-queue-already-exists-tp4675161.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How to check if a queue already exists

Posted by Timothy Bish <ta...@gmail.com>.
Christian sums it up pretty nicely. However if you insist that using 
advisories is the way to go there are some examples of using advisory 
consumers in the CMS examples dir.  Also in the 3.8.0 line there is now 
a DestinationSource in CMS that you can get from the Connection instance 
which will allow you to monitor Destinations on the broker so long as 
advisories are enabled.  You can see it being used in the Enhanced 
Connection test in the integration tests folder in the CMS src bundle.

On 12/05/2013 09:48 AM, Christian Posta wrote:
> So the bottom line for this is simple, and Tim already mentioned this
> in the other thread:
>
> Enable security (http://activemq.apache.org/security.html) and don't
> let the producer user "create" any destinations. Then allow the
> consumer user to create destinations. Then you can do what you (or the
> OP in the linked thread) want to do.
>
> Though in your case, if the queue names are dynamic, how is the
> producer going to know which queue to use? It can listen on advisory
> messages, but does it know which destination to pick?
>
> On Wed, Dec 4, 2013 at 8:28 PM, ranjanip <ra...@gmail.com> wrote:
>> Hi,
>>
>> I refer to the post in :
>> http://activemq.2283324.n4.nabble.com/How-to-send-a-textMessage-to-an-exising-queue-destination-td3481137.html
>>
>> I have a different situation where I have a Java consumer and a cpp
>> producer. My java side is the consumer, it creates the queueA by connecting
>> to the broker and then the CMS  side being the producer will publish
>> messages to the queueA. This producer should get access to the queueA
>> (already created by Java consumer) and publish to it. If the queue doesnt
>> exist, it shouldnt publish at all. the queue creation is dynamic as the
>> names will be decided at runtime.
>>
>> I tried using the DynamicDestinationResolver to get an access to the
>> existing destination, but realized that it creates a new one if it doesnt
>> already exist.
>>
>> I saw many posts on using advisory, but couldnt find any sample usage for
>> the cms side. Any help on this will be greatly appreciated. Please let me
>> know if I should add any other info here.
>>
>> Thanks,
>> Ranjani
>>
>>
>>
>> --
>> View this message in context: http://activemq.2283324.n4.nabble.com/How-to-check-if-a-queue-already-exists-tp4675161.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: How to check if a queue already exists

Posted by ranjanip <ra...@gmail.com>.
Thanks Christian and Tim for the prompt responses.

I'll try that. Both my producer and consumer have a logic to generate the
same name.

As of now, I tried the advisory example from here:
http://activemq.apache.org/cms/handling-advisory-messages.html and it works.

Trying out this security configuration as you suggest. It looks like less
overhead and to my purpose. Will update the status soon.

Regards,
Ranjani


ceposta wrote
> So the bottom line for this is simple, and Tim already mentioned this
> in the other thread:
> 
> Enable security (http://activemq.apache.org/security.html) and don't
> let the producer user "create" any destinations. Then allow the
> consumer user to create destinations. Then you can do what you (or the
> OP in the linked thread) want to do.
> 
> Though in your case, if the queue names are dynamic, how is the
> producer going to know which queue to use? It can listen on advisory
> messages, but does it know which destination to pick?
> 
> On Wed, Dec 4, 2013 at 8:28 PM, ranjanip &lt;

> ranjani.in@

> &gt; wrote:
>> Hi,
>>
>> I refer to the post in :
>> http://activemq.2283324.n4.nabble.com/How-to-send-a-textMessage-to-an-exising-queue-destination-td3481137.html
>>
>> I have a different situation where I have a Java consumer and a cpp
>> producer. My java side is the consumer, it creates the queueA by
>> connecting
>> to the broker and then the CMS  side being the producer will publish
>> messages to the queueA. This producer should get access to the queueA
>> (already created by Java consumer) and publish to it. If the queue doesnt
>> exist, it shouldnt publish at all. the queue creation is dynamic as the
>> names will be decided at runtime.
>>
>> I tried using the DynamicDestinationResolver to get an access to the
>> existing destination, but realized that it creates a new one if it doesnt
>> already exist.
>>
>> I saw many posts on using advisory, but couldnt find any sample usage for
>> the cms side. Any help on this will be greatly appreciated. Please let me
>> know if I should add any other info here.
>>
>> Thanks,
>> Ranjani
>>
>>
>>
>> --
>> View this message in context:
>> http://activemq.2283324.n4.nabble.com/How-to-check-if-a-queue-already-exists-tp4675161.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> 
> 
> 
> -- 
> Christian Posta
> http://www.christianposta.com/blog
> twitter: @christianposta





--
View this message in context: http://activemq.2283324.n4.nabble.com/How-to-check-if-a-queue-already-exists-tp4675161p4675274.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How to check if a queue already exists

Posted by Christian Posta <ch...@gmail.com>.
So the bottom line for this is simple, and Tim already mentioned this
in the other thread:

Enable security (http://activemq.apache.org/security.html) and don't
let the producer user "create" any destinations. Then allow the
consumer user to create destinations. Then you can do what you (or the
OP in the linked thread) want to do.

Though in your case, if the queue names are dynamic, how is the
producer going to know which queue to use? It can listen on advisory
messages, but does it know which destination to pick?

On Wed, Dec 4, 2013 at 8:28 PM, ranjanip <ra...@gmail.com> wrote:
> Hi,
>
> I refer to the post in :
> http://activemq.2283324.n4.nabble.com/How-to-send-a-textMessage-to-an-exising-queue-destination-td3481137.html
>
> I have a different situation where I have a Java consumer and a cpp
> producer. My java side is the consumer, it creates the queueA by connecting
> to the broker and then the CMS  side being the producer will publish
> messages to the queueA. This producer should get access to the queueA
> (already created by Java consumer) and publish to it. If the queue doesnt
> exist, it shouldnt publish at all. the queue creation is dynamic as the
> names will be decided at runtime.
>
> I tried using the DynamicDestinationResolver to get an access to the
> existing destination, but realized that it creates a new one if it doesnt
> already exist.
>
> I saw many posts on using advisory, but couldnt find any sample usage for
> the cms side. Any help on this will be greatly appreciated. Please let me
> know if I should add any other info here.
>
> Thanks,
> Ranjani
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/How-to-check-if-a-queue-already-exists-tp4675161.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



-- 
Christian Posta
http://www.christianposta.com/blog
twitter: @christianposta