You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by himmeric <hi...@vnet.ibm.com> on 2006/05/15 17:38:41 UTC

Problem with No Subscriber Advisory Topic

I'm using the advisory topics in ActiveMQ 4 to watch when a new topic is
created on a certain subtopic.  This works great and allows me to startup
the producer that generates message for subscribers on this new topic.

However it also important for me to know when there are no more subscribers
so I can stop the producer.  I see the
AdvisorySupport.getNoTopicConsumersAdvisoryTopic and I've setup a consumer
to that topic, but I'm not receiving any messages on it.

I'm assuming this no topic consumers functionality works and it's just
something in my  setup causing the problem.  So here's a little about my
config.

I'm using topics, with persistent messages.  My subscriptions are setup with
?retroactive=true and am using the LastImageSubscriptionRecoveryPolicy.  I'm
running RC-3 on linux under IBM JDK 1.4.2

I am receiving messages on the .getConsumerAdvisoryTopic when a single
consumer is added or removed, but not on the
.getNoTopicConsumersAdvisoryTopic when there are no consumers on the topic.

What am I missing?
--
View this message in context: http://www.nabble.com/Problem-with-No-Subscriber-Advisory-Topic-t1621608.html#a4393897
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by himmeric <hi...@vnet.ibm.com>.
Nevermind, using a wildcard here doesn't make sense as the consumerCount is
based on the ConsumerEventSource destination, not child destinations.


--
View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4613848
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by himmeric <hi...@vnet.ibm.com>.
Thanks for the follow up.

I checked out the ConsumerEventSource, that'll work pretty well.

One question with them though, if I setup to a wildcard destination (eg
status.>) is there a way to get at the actual destination that caused the
event in onConsumerEvent(event).  event.getDestination shows the original
config 'status.>' not 'status.foo'

I can see the ConsumerInfo object in debug has the full destination but
don't see a way to get to it.

Thanks!
--
View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4604156
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by Hiram Chirino <hi...@hiramchirino.com>.
If you don't trust your own counters just use the ConsumerEventSource,
it provides a reliable count for you.  If you want to have some
timeout condition, you could do your own client side timeout.  There
are lots of ways to do this, but a recent idea to help with this is
beanflow, see:
http://servicemix.org/site/beanflow.html
It supports adding simple workflow style timeouts.

On 5/24/06, himmeric <hi...@vnet.ibm.com> wrote:
>
> Thanks I was considering that, but didn't trust the integrity of my own
> internal counter.  Since shutting down a producer when there are still
> consumers would be very bad.
>
> For now I'm using the command line query tool to check for periodic
> ConsumerCount=0.
>
> Maybe a better approach would be to use the ConsumerListener class for an
> internal counter with a periodic sanity check using command line tool to
> make sure I didnt shut down something I hadn't.
>
> This could probably be done with JMX too, but I got lost pretty quickly in
> that (new to jmx).
>
> I opened a feature request here:
> http://issues.apache.org/activemq/browse/AMQ-723
> --
> View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4551149
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 
Regards,
Hiram

Re: Problem with No Subscriber Advisory Topic

Posted by himmeric <hi...@vnet.ibm.com>.
Thanks I was considering that, but didn't trust the integrity of my own
internal counter.  Since shutting down a producer when there are still
consumers would be very bad.

For now I'm using the command line query tool to check for periodic
ConsumerCount=0.

Maybe a better approach would be to use the ConsumerListener class for an
internal counter with a periodic sanity check using command line tool to
make sure I didnt shut down something I hadn't.

This could probably be done with JMX too, but I got lost pretty quickly in
that (new to jmx).

I opened a feature request here:
http://issues.apache.org/activemq/browse/AMQ-723
--
View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4551149
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by Hiram Chirino <hi...@hiramchirino.com>.
And a more simple approach would be to use the

org.apache.activemq.advisory.ConsumerEventSource class and let it
notify your implementation of the ConsumerListener class with
ConsumerStartedEvent and ConsumerStoppedEvent objects.


On 5/24/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> Himmeric,
>
> The consumer advisory topic will let you know when consumer come
> online and also offline.  You could maintain a reference counter and
> when it dops to zero, you would know there no active consumers on the
> topic.
>
> The message sent on the topic when a consumer goes offline is of type
> RemoveInfo.
>
> On 5/24/06, himmeric <hi...@vnet.ibm.com> wrote:
> >
> > Oh so I misunderstood altoghether the purpose of the topic, come to think of
> > it I didn't read anything on it just took a leap of faith when I saw the
> > name.
> >
> > Thanks for checking it out and setting me straight.
> >
> > I'll open an enhancement request to receive an advisory message when the
> > last subscriber leaves a topic.
> > --
> > View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4542304
> > Sent from the ActiveMQ - User forum at Nabble.com.
> >
> >
>
>
> --
> Regards,
> Hiram
>


-- 
Regards,
Hiram

Re: Problem with No Subscriber Advisory Topic

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Himmeric,

The consumer advisory topic will let you know when consumer come
online and also offline.  You could maintain a reference counter and
when it dops to zero, you would know there no active consumers on the
topic.

The message sent on the topic when a consumer goes offline is of type
RemoveInfo.

On 5/24/06, himmeric <hi...@vnet.ibm.com> wrote:
>
> Oh so I misunderstood altoghether the purpose of the topic, come to think of
> it I didn't read anything on it just took a leap of faith when I saw the
> name.
>
> Thanks for checking it out and setting me straight.
>
> I'll open an enhancement request to receive an advisory message when the
> last subscriber leaves a topic.
> --
> View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4542304
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 
Regards,
Hiram

Re: Problem with No Subscriber Advisory Topic

Posted by himmeric <hi...@vnet.ibm.com>.
Oh so I misunderstood altoghether the purpose of the topic, come to think of
it I didn't read anything on it just took a leap of faith when I saw the
name.

Thanks for checking it out and setting me straight.

I'll open an enhancement request to receive an advisory message when the
last subscriber leaves a topic.
--
View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4542304
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by Adrian Co <ac...@exist.com>.
Hi,

Sorry, I grokked the code, and it is only applicable to non-persistent
messages only. Its behavior is like a dead letter queue.

You could file a JIRA for it, if you want with the use case you are using.
:)

Regards,
Adrian
--
View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4534733
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by himmeric <hi...@vnet.ibm.com>.
Thanks for the suggestion Adrian, I didn't realize that was necessary.
Unfortunately it didn't seem to fix my problem.

I still receive a ConsumerInfo and a RemoveInfo on the 
topic://ActiveMQ.Advisory.Consumer.Topic.status.test

But no messages on topic://ActiveMQ.Advisory.NoConsumer.Topic.status.test

Using the command line query tool I see the 'Subscription' to
topic://ActiveMQ.Advisory.NoConsumer.Topic.status.test, but I don't see a
'Topic' topic://ActiveMQ.Advisory.NoConsumer.Topic.status.test, which I
think means that no messages were ever published to that topic.

Also using the query tool I can see that the status.test topic has 0
consumers.

Is this policy flag new, my snapshot is about a week old.

--
View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4528097
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by Adrian Co <ac...@exist.com>.
Hi,

Could you try setting this flag in your destination policy:
sendAdvisoryIfNoConsumers="true"

i.e.

    <destinationPolicy>
      <policyMap><policyEntries>
        
          <policyEntry topic="TEST.FOO" sendAdvisoryIfNoConsumers="true">
            <dispatchPolicy>
              <strictOrderDispatchPolicy />
            </dispatchPolicy>
            <subscriptionRecoveryPolicy>
              <lastImageSubscriptionRecoveryPolicy />
            </subscriptionRecoveryPolicy>
          </policyEntry>

      </policyEntries></policyMap>
    </destinationPolicy>

Let me know if that fixes your problem. :)

Regards,
Adrian Co


himmeric wrote:
> 
> I forgot to mention I'm using a wildcard to setup my
> getConsumerAdvisoryTopic, which seems to work fine.   "topic.>" and I
> receive advisory messages on all subtopics.  
> 
> Since I'm having a problem with the no consumers advisrory I tried that
> with a wildcard "topic.>" and also as individual consumers when the topic
> is created, "topic.subtopicA"  neither seem to receive messages when there
> are no consumers left.
> 
> I'm thinking that the wildcard approach should work for the no consumer
> advisory as well, since the advisory topics appear to be just normal
> topics.
> 
--
View this message in context: http://www.nabble.com/Problem+with+No+Subscriber+Advisory+Topic-t1621608.html#a4516715
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Problem with No Subscriber Advisory Topic

Posted by himmeric <hi...@vnet.ibm.com>.
I forgot to mention I'm using a wildcard to setup my
getConsumerAdvisoryTopic, which seems to work fine.   "topic.>" and I
receive advisory messages on all subtopics.  

Since I'm having a problem with the no consumers advisrory I tried that with
a wildcard "topic.>" and also as individual consumers when the topic is
created, "topic.subtopicA"  neither seem to receive messages when there are
no consumers left.

I'm thinking that the wildcard approach should work for the no consumer
advisory as well, since the advisory topics appear to be just normal topics.
--
View this message in context: http://www.nabble.com/Problem-with-No-Subscriber-Advisory-Topic-t1621608.html#a4394011
Sent from the ActiveMQ - User forum at Nabble.com.