You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by darrickc <da...@gmail.com> on 2009/02/06 23:49:00 UTC

Can someone point me to an example of using a ConsumerEventSource

I have an embedded broker in my server process and I'd like to know in my
server process when a client subscribes to a certain topic. Through reading
these forums I've figured out that using a ConsumerEventSource is the way to
go. When I get an event I can figure out how many consumers there are for a
topic like:

public void onConsumerEvent( ConsumerEvent consumerEvt )
{
	numOfConsumers = consumerEvt.getConsumerCount()
}

Here is how I've setup my consumer for ConsumerEvents:


// here topic is something like "Something.status.STOP" 
//but I've also tried "ActiveMQ.Advisory.Consumer.Topic."+topic
destination = session.createTopic(topic);

//Here the connection is the connection in the server that is used to
publish messages on to the consumers.
ConsumerEventSource ces = new ConsumerEventSource(connection, destination);
ConsumerListener listener = new SubscriberListener(topic);
//subscriberListener implements ConsumerListener
ces.setConsumerListener( listener );

Am I missing something here?
-- 
View this message in context: http://www.nabble.com/Can-someone-point-me-to-an-example-of-using-a-ConsumerEventSource-tp21882293p21882293.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Can someone point me to an example of using a ConsumerEventSource

Posted by Eric-AWL <er...@atosorigin.com>.
Hi everybody

I will be in a network of brokers configuration where consumers are not
directly created on the current  embedded broker used by my current
connection.

I have some questions about this way to know how many consumers are attached
to a queue or a topic.

Will I receive such kind of event when my embedded broker connects to a new
distant broker where a consumer exists for this queue/topic ?
Will I receive such kind of event when a distant broker which has a consumer
for this queue/topic, disappears ?
What is the best way to know how many consumers exist for a producer just
created ? Is there a way to know this information without trying to send a
message on the queue/topic associated with the producer ?

Thank you very much for your answers
Eric-AWL


-- 
View this message in context: http://www.nabble.com/Can-someone-point-me-to-an-example-of-using-a-ConsumerEventSource-tp21882293p23114739.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Can someone point me to an example of using a ConsumerEventSource

Posted by darrickc <da...@gmail.com>.
That did the trick! Thanks!



Dejan Bosanac wrote:
> 
> Hi,
> 
> try starting the ConsumerEvenetSource (ces.start()).
> 
> Cheers
> --
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Fri, Feb 6, 2009 at 11:49 PM, darrickc <da...@gmail.com> wrote:
> 
>>
>> I have an embedded broker in my server process and I'd like to know in my
>> server process when a client subscribes to a certain topic. Through
>> reading
>> these forums I've figured out that using a ConsumerEventSource is the way
>> to
>> go. When I get an event I can figure out how many consumers there are for
>> a
>> topic like:
>>
>> public void onConsumerEvent( ConsumerEvent consumerEvt )
>> {
>>        numOfConsumers = consumerEvt.getConsumerCount()
>> }
>>
>> Here is how I've setup my consumer for ConsumerEvents:
>>
>>
>> // here topic is something like "Something.status.STOP"
>> //but I've also tried "ActiveMQ.Advisory.Consumer.Topic."+topic
>> destination = session.createTopic(topic);
>>
>> //Here the connection is the connection in the server that is used to
>> publish messages on to the consumers.
>> ConsumerEventSource ces = new ConsumerEventSource(connection,
>> destination);
>> ConsumerListener listener = new SubscriberListener(topic);
>> //subscriberListener implements ConsumerListener
>> ces.setConsumerListener( listener );
>>
>> Am I missing something here?
>> --
>> View this message in context:
>> http://www.nabble.com/Can-someone-point-me-to-an-example-of-using-a-ConsumerEventSource-tp21882293p21882293.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 

-- 
View this message in context: http://www.nabble.com/Can-someone-point-me-to-an-example-of-using-a-ConsumerEventSource-tp21882293p21922620.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Can someone point me to an example of using a ConsumerEventSource

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi,

try starting the ConsumerEvenetSource (ces.start()).

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Fri, Feb 6, 2009 at 11:49 PM, darrickc <da...@gmail.com> wrote:

>
> I have an embedded broker in my server process and I'd like to know in my
> server process when a client subscribes to a certain topic. Through reading
> these forums I've figured out that using a ConsumerEventSource is the way
> to
> go. When I get an event I can figure out how many consumers there are for a
> topic like:
>
> public void onConsumerEvent( ConsumerEvent consumerEvt )
> {
>        numOfConsumers = consumerEvt.getConsumerCount()
> }
>
> Here is how I've setup my consumer for ConsumerEvents:
>
>
> // here topic is something like "Something.status.STOP"
> //but I've also tried "ActiveMQ.Advisory.Consumer.Topic."+topic
> destination = session.createTopic(topic);
>
> //Here the connection is the connection in the server that is used to
> publish messages on to the consumers.
> ConsumerEventSource ces = new ConsumerEventSource(connection, destination);
> ConsumerListener listener = new SubscriberListener(topic);
> //subscriberListener implements ConsumerListener
> ces.setConsumerListener( listener );
>
> Am I missing something here?
> --
> View this message in context:
> http://www.nabble.com/Can-someone-point-me-to-an-example-of-using-a-ConsumerEventSource-tp21882293p21882293.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>