# How to Listen to a Rabbitmq Queue Events

**URL:** <https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129>\
**Category:** googlegroup\
**Created:** [April 24, 2016, 1:16am UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129 "2016-04-24T01:16:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![geeta\_raghu\_vamsi\_ko](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@geeta\_raghu\_vamsi\_ko](https://discourse.nameko.io/u/geeta_raghu_vamsi_ko)\
**Post date:** [April 24, 2016, 1:16am UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129/1 "2016-04-24T01:16:00Z")

</div>

i'm not sure if my understanding with the documentation is correct but my  
question here is can the event\_handler {ServicePool,Broadcast,Singleton}  
listen to the Rabbitmq server for the events and for a standard usecase how  
to use the event\_handler to listen to the events?I'm bit confused on the  
examples that are being shared in the repo.

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [April 24, 2016, 12:51pm UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129/2 "2016-04-24T12:51:38Z")

</div>

An Event is a nameko construct. You can use the EventDispatcher to dispatch  
events from services, and the event\_handler to receive them. It's an  
implementation of the publisher-subscriber pattern which happens to use  
AMQP.

I guess what you're really asking about is how to consume regular AMQP  
messages with a nameko service. If so, this is possible, and has been asked  
about on the forum before.  
See [https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ](https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ) for  
more.

Does that help?

> **···**
>
> On Sunday, April 24, 2016 at 2:16:00 AM UTC+1, geeta raghu vamsi kotipalli wrote:
> 
> > i'm not sure if my understanding with the documentation is correct but my  
> > question here is can the event\_handler {ServicePool,Broadcast,Singleton}  
> > listen to the Rabbitmq server for the events and for a standard usecase how  
> > to use the event\_handler to listen to the events?I'm bit confused on the  
> > examples that are being shared in the repo.

---

<div class="post-metadata">

**Author:** ![geeta\_raghu\_vamsi\_ko](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@geeta\_raghu\_vamsi\_ko](https://discourse.nameko.io/u/geeta_raghu_vamsi_ko)\
**Post date:** [April 25, 2016, 3:29pm UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129/3 "2016-04-25T15:29:39Z")

</div>

Thanks Matt for the reference i got it working but i have another scenario  
where i need to listen to multiple AMQP services which the decorators  
trigger to different functions inside the service container

Example

config.yaml

AMQP\_URL\_1 = [http://localhost:7777/testing](http://localhost:7777/testing)  
AMQP\_URL\_2 = [http://localhost:8888/test](http://localhost:8888/test)

service.py

from kombu import Queue

amq\_one = Queue('testing')  
amq\_two = Queue('test')

class Testing(object):  
&nbsp;&nbsp;  
&nbsp;&nbsp;@consume(amq\_one)  
&nbsp;&nbsp;def testing(self,msg):  
&nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 1"

&nbsp;&nbsp;@consume(amq\_two)  
&nbsp;&nbsp;&nbsp;def test(self,msg):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 2"

Thanks,  
Vamsi

> **···**
>
> On Sunday, April 24, 2016 at 7:51:39 AM UTC-5, Matt Bennett wrote:
> 
> > An Event is a nameko construct. You can use the EventDispatcher to  
> > dispatch events from services, and the event\_handler to receive them. It's  
> > an implementation of the publisher-subscriber pattern which happens to use  
> > AMQP.
> > 
> > I guess what you're really asking about is how to consume regular AMQP  
> > messages with a nameko service. If so, this is possible, and has been asked  
> > about on the forum before. See  
> > [https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ](https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ) for  
> > more.
> > 
> > Does that help?
> > 
> > On Sunday, April 24, 2016 at 2:16:00 AM UTC+1, geeta raghu vamsi kotipalli \> wrote:
> > 
> > > i'm not sure if my understanding with the documentation is correct but my  
> > > question here is can the event\_handler {ServicePool,Broadcast,Singleton}  
> > > listen to the Rabbitmq server for the events and for a standard usecase how  
> > > to use the event\_handler to listen to the events?I'm bit confused on the  
> > > examples that are being shared in the repo.

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [April 25, 2016, 9:50pm UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129/4 "2016-04-25T21:50:41Z")

</div>

Unfortunately this is not possible. You will have to use two services, or  
you may want to look at the RabbitMQ shovel  
\<[https://www.rabbitmq.com/shovel.html&gt](https://www.rabbitmq.com/shovel.html&gt); to move messages between brokers.

> **···**
>
> On Monday, April 25, 2016 at 4:29:39 PM UTC+1, geeta raghu vamsi kotipalli wrote:
> 
> > Thanks Matt for the reference i got it working but i have another scenario  
> > where i need to listen to multiple AMQP services which the decorators  
> > trigger to different functions inside the service container
> > 
> > Example
> > 
> > config.yaml
> > 
> > AMQP\_URL\_1 = [http://localhost:7777/testing](http://localhost:7777/testing)  
> > AMQP\_URL\_2 = [http://localhost:8888/test](http://localhost:8888/test)
> > 
> > service.py
> > 
> > from kombu import Queue
> > 
> > amq\_one = Queue('testing')  
> > amq\_two = Queue('test')
> > 
> > class Testing(object):  
> > &nbsp;&nbsp;  
> > &nbsp;&nbsp;@consume(amq\_one)  
> > &nbsp;&nbsp;def testing(self,msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 1"
> > 
> > &nbsp;&nbsp;@consume(amq\_two)  
> > &nbsp;&nbsp;&nbsp;def test(self,msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 2"
> > 
> > Thanks,  
> > Vamsi
> > 
> > On Sunday, April 24, 2016 at 7:51:39 AM UTC-5, Matt Bennett wrote:
> > 
> > > An Event is a nameko construct. You can use the EventDispatcher to  
> > > dispatch events from services, and the event\_handler to receive them. It's  
> > > an implementation of the publisher-subscriber pattern which happens to use  
> > > AMQP.
> > > 
> > > I guess what you're really asking about is how to consume regular AMQP  
> > > messages with a nameko service. If so, this is possible, and has been asked  
> > > about on the forum before. See  
> > > [https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ](https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ) for  
> > > more.
> > > 
> > > Does that help?
> > > 
> > > On Sunday, April 24, 2016 at 2:16:00 AM UTC+1, geeta raghu vamsi \>\> kotipalli wrote:
> > > 
> > > > i'm not sure if my understanding with the documentation is correct but  
> > > > my question here is can the event\_handler {ServicePool,Broadcast,Singleton}  
> > > > listen to the Rabbitmq server for the events and for a standard usecase how  
> > > > to use the event\_handler to listen to the events?I'm bit confused on the  
> > > > examples that are being shared in the repo.

---

<div class="post-metadata">

**Author:** ![geeta\_raghu\_vamsi\_ko](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@geeta\_raghu\_vamsi\_ko](https://discourse.nameko.io/u/geeta_raghu_vamsi_ko)\
**Post date:** [May 2, 2016, 3:22pm UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129/5 "2016-05-02T15:22:21Z")

</div>

Should i make changes on the Rabbitmq server to enable shovel so that my  
client gets those events or i need to do it at the client side.

Thanks,  
Vamsi

> **···**
>
> On Monday, April 25, 2016 at 4:50:41 PM UTC-5, Matt Bennett wrote:
> 
> > Unfortunately this is not possible. You will have to use two services, or  
> > you may want to look at the RabbitMQ shovel  
> > \<[https://www.rabbitmq.com/shovel.html&gt](https://www.rabbitmq.com/shovel.html&gt); to move messages between brokers.
> > 
> > On Monday, April 25, 2016 at 4:29:39 PM UTC+1, geeta raghu vamsi kotipalli \> wrote:
> > 
> > > Thanks Matt for the reference i got it working but i have another  
> > > scenario where i need to listen to multiple AMQP services which the  
> > > decorators trigger to different functions inside the service container
> > > 
> > > Example
> > > 
> > > config.yaml
> > > 
> > > AMQP\_URL\_1 = [http://localhost:7777/testing](http://localhost:7777/testing)  
> > > AMQP\_URL\_2 = [http://localhost:8888/test](http://localhost:8888/test)
> > > 
> > > service.py
> > > 
> > > from kombu import Queue
> > > 
> > > amq\_one = Queue('testing')  
> > > amq\_two = Queue('test')
> > > 
> > > class Testing(object):  
> > > &nbsp;&nbsp;  
> > > &nbsp;&nbsp;@consume(amq\_one)  
> > > &nbsp;&nbsp;def testing(self,msg):  
> > > &nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 1"
> > > 
> > > &nbsp;&nbsp;@consume(amq\_two)  
> > > &nbsp;&nbsp;&nbsp;def test(self,msg):  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 2"
> > > 
> > > Thanks,  
> > > Vamsi
> > > 
> > > On Sunday, April 24, 2016 at 7:51:39 AM UTC-5, Matt Bennett wrote:
> > > 
> > > > An Event is a nameko construct. You can use the EventDispatcher to  
> > > > dispatch events from services, and the event\_handler to receive them. It's  
> > > > an implementation of the publisher-subscriber pattern which happens to use  
> > > > AMQP.
> > > > 
> > > > I guess what you're really asking about is how to consume regular AMQP  
> > > > messages with a nameko service. If so, this is possible, and has been asked  
> > > > about on the forum before. See  
> > > > [https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ](https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ) for  
> > > > more.
> > > > 
> > > > Does that help?
> > > > 
> > > > On Sunday, April 24, 2016 at 2:16:00 AM UTC+1, geeta raghu vamsi \>\>\> kotipalli wrote:
> > > > 
> > > > > i'm not sure if my understanding with the documentation is correct but  
> > > > > my question here is can the event\_handler {ServicePool,Broadcast,Singleton}  
> > > > > listen to the Rabbitmq server for the events and for a standard usecase how  
> > > > > to use the event\_handler to listen to the events?I'm bit confused on the  
> > > > > examples that are being shared in the repo.

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [May 2, 2016, 3:53pm UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129/6 "2016-05-02T15:53:23Z")

</div>

Shovel is a plugin for the broker -- it's all server-side.

I'm suggesting that you use shovel to move messages from one broker to  
another, so you can connect your nameko service to just one of them.

> **···**
>
> On Monday, May 2, 2016 at 4:22:21 PM UTC+1, geeta raghu vamsi kotipalli wrote:
> 
> > Should i make changes on the Rabbitmq server to enable shovel so that my  
> > client gets those events or i need to do it at the client side.
> > 
> > Thanks,  
> > Vamsi
> > 
> > On Monday, April 25, 2016 at 4:50:41 PM UTC-5, Matt Bennett wrote:
> > 
> > > Unfortunately this is not possible. You will have to use two services, or  
> > > you may want to look at the RabbitMQ shovel  
> > > \<[https://www.rabbitmq.com/shovel.html&gt](https://www.rabbitmq.com/shovel.html&gt); to move messages between brokers.
> > > 
> > > On Monday, April 25, 2016 at 4:29:39 PM UTC+1, geeta raghu vamsi \>\> kotipalli wrote:
> > > 
> > > > Thanks Matt for the reference i got it working but i have another  
> > > > scenario where i need to listen to multiple AMQP services which the  
> > > > decorators trigger to different functions inside the service container
> > > > 
> > > > Example
> > > > 
> > > > config.yaml
> > > > 
> > > > AMQP\_URL\_1 = [http://localhost:7777/testing](http://localhost:7777/testing)  
> > > > AMQP\_URL\_2 = [http://localhost:8888/test](http://localhost:8888/test)
> > > > 
> > > > service.py
> > > > 
> > > > from kombu import Queue
> > > > 
> > > > amq\_one = Queue('testing')  
> > > > amq\_two = Queue('test')
> > > > 
> > > > class Testing(object):  
> > > > &nbsp;&nbsp;  
> > > > &nbsp;&nbsp;@consume(amq\_one)  
> > > > &nbsp;&nbsp;def testing(self,msg):  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 1"
> > > > 
> > > > &nbsp;&nbsp;@consume(amq\_two)  
> > > > &nbsp;&nbsp;&nbsp;def test(self,msg):  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 2"
> > > > 
> > > > Thanks,  
> > > > Vamsi
> > > > 
> > > > On Sunday, April 24, 2016 at 7:51:39 AM UTC-5, Matt Bennett wrote:
> > > > 
> > > > > An Event is a nameko construct. You can use the EventDispatcher to  
> > > > > dispatch events from services, and the event\_handler to receive them. It's  
> > > > > an implementation of the publisher-subscriber pattern which happens to use  
> > > > > AMQP.
> > > > > 
> > > > > I guess what you're really asking about is how to consume regular AMQP  
> > > > > messages with a nameko service. If so, this is possible, and has been asked  
> > > > > about on the forum before. See  
> > > > > [https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ](https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ)  
> > > > > for more.
> > > > > 
> > > > > Does that help?
> > > > > 
> > > > > On Sunday, April 24, 2016 at 2:16:00 AM UTC+1, geeta raghu vamsi \>\>\>\> kotipalli wrote:
> > > > > 
> > > > > > i'm not sure if my understanding with the documentation is correct but  
> > > > > > my question here is can the event\_handler {ServicePool,Broadcast,Singleton}  
> > > > > > listen to the Rabbitmq server for the events and for a standard usecase how  
> > > > > > to use the event\_handler to listen to the events?I'm bit confused on the  
> > > > > > examples that are being shared in the repo.

---

<div class="post-metadata">

**Author:** ![geeta\_raghu\_vamsi\_ko](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@geeta\_raghu\_vamsi\_ko](https://discourse.nameko.io/u/geeta_raghu_vamsi_ko)\
**Post date:** [May 2, 2016, 4:13pm UTC](https://discourse.nameko.io/t/how-to-listen-to-a-rabbitmq-queue-events/129/7 "2016-05-02T16:13:07Z")

</div>

Infact this implementation is totally to communicate multiple datacenters  
across the globe and the server setup is so static and changing or  
including a plugin or component needs lots of mail chains for approval so  
was thinking for a easy solution around.

> **···**
>
> On Monday, May 2, 2016 at 10:53:23 AM UTC-5, Matt Bennett wrote:
> 
> > Shovel is a plugin for the broker -- it's all server-side.
> > 
> > I'm suggesting that you use shovel to move messages from one broker to  
> > another, so you can connect your nameko service to just one of them.
> > 
> > On Monday, May 2, 2016 at 4:22:21 PM UTC+1, geeta raghu vamsi kotipalli \> wrote:
> > 
> > > Should i make changes on the Rabbitmq server to enable shovel so that my  
> > > client gets those events or i need to do it at the client side.
> > > 
> > > Thanks,  
> > > Vamsi
> > > 
> > > On Monday, April 25, 2016 at 4:50:41 PM UTC-5, Matt Bennett wrote:
> > > 
> > > > Unfortunately this is not possible. You will have to use two services,  
> > > > or you may want to look at the RabbitMQ shovel  
> > > > \<[https://www.rabbitmq.com/shovel.html&gt](https://www.rabbitmq.com/shovel.html&gt); to move messages between brokers.
> > > > 
> > > > On Monday, April 25, 2016 at 4:29:39 PM UTC+1, geeta raghu vamsi \>\>\> kotipalli wrote:
> > > > 
> > > > > Thanks Matt for the reference i got it working but i have another  
> > > > > scenario where i need to listen to multiple AMQP services which the  
> > > > > decorators trigger to different functions inside the service container
> > > > > 
> > > > > Example
> > > > > 
> > > > > config.yaml
> > > > > 
> > > > > AMQP\_URL\_1 = [http://localhost:7777/testing](http://localhost:7777/testing)  
> > > > > AMQP\_URL\_2 = [http://localhost:8888/test](http://localhost:8888/test)
> > > > > 
> > > > > service.py
> > > > > 
> > > > > from kombu import Queue
> > > > > 
> > > > > amq\_one = Queue('testing')  
> > > > > amq\_two = Queue('test')
> > > > > 
> > > > > class Testing(object):  
> > > > > &nbsp;&nbsp;  
> > > > > &nbsp;&nbsp;@consume(amq\_one)  
> > > > > &nbsp;&nbsp;def testing(self,msg):  
> > > > > &nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 1"
> > > > > 
> > > > > &nbsp;&nbsp;@consume(amq\_two)  
> > > > > &nbsp;&nbsp;&nbsp;def test(self,msg):  
> > > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Message from AMQP 2"
> > > > > 
> > > > > Thanks,  
> > > > > Vamsi
> > > > > 
> > > > > On Sunday, April 24, 2016 at 7:51:39 AM UTC-5, Matt Bennett wrote:
> > > > > 
> > > > > > An Event is a nameko construct. You can use the EventDispatcher to  
> > > > > > dispatch events from services, and the event\_handler to receive them. It's  
> > > > > > an implementation of the publisher-subscriber pattern which happens to use  
> > > > > > AMQP.
> > > > > > 
> > > > > > I guess what you're really asking about is how to consume regular AMQP  
> > > > > > messages with a nameko service. If so, this is possible, and has been asked  
> > > > > > about on the forum before. See  
> > > > > > [https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ](https://groups.google.com/d/msg/nameko-dev/4CBsB4rLFrM/klcnkYU9AwAJ)  
> > > > > > for more.
> > > > > > 
> > > > > > Does that help?
> > > > > > 
> > > > > > On Sunday, April 24, 2016 at 2:16:00 AM UTC+1, geeta raghu vamsi \>\>\>\>\> kotipalli wrote:
> > > > > > 
> > > > > > > i'm not sure if my understanding with the documentation is correct  
> > > > > > > but my question here is can the event\_handler  
> > > > > > > {ServicePool,Broadcast,Singleton} listen to the Rabbitmq server for the  
> > > > > > > events and for a standard usecase how to use the event\_handler to listen to  
> > > > > > > the events?I'm bit confused on the examples that are being shared in the  
> > > > > > > repo.
