You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by KrisVH <kr...@digipolis.gent> on 2016/10/24 16:05:05 UTC

Avoid always creating a subscription to a topic when connecting as durable subscriber?

Hi,

I want to have a thing where you can subscribe to a topic as a durable
subscriber. Then afterwards you get the messages whenever, and when you
don't want to get any more messages, you can unsubscribe.

I have all this working fine, but if you then try to connect with the same
subscription ID you used (=the one you unsubscribed with), you automatically
recreate the subscription again.

I want it instead to tell me that I don't have an active subscription, and
certainly not create the subscription again.

So, as I have it now:

-create sub => ok, sub is created
-get messages => ok, messages are gotten
-unsub => ok, sub is removed and messages aren't received
-get messages => sub is recreated and future messages will be delivered

But the way I want it is:

-create sub => ok, sub is created
-get messages => ok, messages are gotten
-unsub => ok, sub is removed and messages aren't received
-get messages => you don't have a sub, go away

Is there a way to connect to AMQ and try to read a topic, without
automatically creating the subscription if I don't have one yet? Or, barring
that, at least check in advance if I actually have a subscription before I
try reading it?

Best regards,

Kris



--
View this message in context: http://activemq.2283324.n4.nabble.com/Avoid-always-creating-a-subscription-to-a-topic-when-connecting-as-durable-subscriber-tp4718372.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Avoid always creating a subscription to a topic when connecting as durable subscriber?

Posted by Clebert Suconic <cl...@gmail.com>.
you will have to check on the server if you have the subscription. +1
on Tim Bain. about using JMX.

If you were using ARtemis, you would be able to query for the
existence of the queue using the core API as well.

On Wed, Oct 26, 2016 at 3:11 PM, Tim Bain <tb...@alumni.duke.edu> wrote:
> You could determine if you have an existing subscription via JMX.
> http://activemq.apache.org/jmx.html
>
> On Oct 25, 2016 2:21 AM, "KrisVH" <kr...@digipolis.gent> wrote:
>
> The broker is currently 5.13.1, and the client is a WSO2 ESB.
>
> The connection is made with Java code, this should be all the relevant code:
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.
> nabble.com/Avoid-always-creating-a-subscription-to-a-
> topic-when-connecting-as-durable-subscriber-tp4718372p4718433.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



-- 
Clebert Suconic

Re: Avoid always creating a subscription to a topic when connecting as durable subscriber?

Posted by Tim Bain <tb...@alumni.duke.edu>.
You could determine if you have an existing subscription via JMX.
http://activemq.apache.org/jmx.html

On Oct 25, 2016 2:21 AM, "KrisVH" <kr...@digipolis.gent> wrote:

The broker is currently 5.13.1, and the client is a WSO2 ESB.

The connection is made with Java code, this should be all the relevant code:





--
View this message in context: http://activemq.2283324.n4.
nabble.com/Avoid-always-creating-a-subscription-to-a-
topic-when-connecting-as-durable-subscriber-tp4718372p4718433.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Avoid always creating a subscription to a topic when connecting as durable subscriber?

Posted by KrisVH <kr...@digipolis.gent>.
The broker is currently 5.13.1, and the client is a WSO2 ESB.

The connection is made with Java code, this should be all the relevant code:





--
View this message in context: http://activemq.2283324.n4.nabble.com/Avoid-always-creating-a-subscription-to-a-topic-when-connecting-as-durable-subscriber-tp4718372p4718433.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Avoid always creating a subscription to a topic when connecting as durable subscriber?

Posted by Justin Bertram <jb...@apache.com>.
Which specific broker are you using (e.g. 5.x or Artemis)?

Also, what kind of client are you using?


Justin

----- Original Message -----
From: "KrisVH" <kr...@digipolis.gent>
To: users@activemq.apache.org
Sent: Monday, October 24, 2016 11:05:05 AM
Subject: Avoid always creating a subscription to a topic when connecting as durable subscriber?

Hi,

I want to have a thing where you can subscribe to a topic as a durable
subscriber. Then afterwards you get the messages whenever, and when you
don't want to get any more messages, you can unsubscribe.

I have all this working fine, but if you then try to connect with the same
subscription ID you used (=the one you unsubscribed with), you automatically
recreate the subscription again.

I want it instead to tell me that I don't have an active subscription, and
certainly not create the subscription again.

So, as I have it now:

-create sub => ok, sub is created
-get messages => ok, messages are gotten
-unsub => ok, sub is removed and messages aren't received
-get messages => sub is recreated and future messages will be delivered

But the way I want it is:

-create sub => ok, sub is created
-get messages => ok, messages are gotten
-unsub => ok, sub is removed and messages aren't received
-get messages => you don't have a sub, go away

Is there a way to connect to AMQ and try to read a topic, without
automatically creating the subscription if I don't have one yet? Or, barring
that, at least check in advance if I actually have a subscription before I
try reading it?

Best regards,

Kris



--
View this message in context: http://activemq.2283324.n4.nabble.com/Avoid-always-creating-a-subscription-to-a-topic-when-connecting-as-durable-subscriber-tp4718372.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.