# "regular" message queueing

**URL:** https://discourse.nameko.io/t/regular-message-queueing/122
**Category:** googlegroup
**Created:** [February 17, 2016, 10:48pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122 "2016-02-17T22:48:47Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Remco\_Boerma](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@Remco\_Boerma](https://discourse.nameko.io/u/Remco_Boerma)
#### Post date: [February 17, 2016, 10:48pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122/1 "2016-02-17T22:48:47Z")

</div>

Hi,

I was searching for a way to use 'regular' queueing in nameko.  
It makes sense to have one service for sending mail. Using RPC from other  
services to this mailer service is possible but let's say i don't need the  
response, so why wait for an answer right? Here are a few options that came  
to mind:

a) call the rpc using async and 'forget' about the response

b) use RPC to call a function in the mailsender that will drop an event to  
itself and return (nearly) instantly and let nameko handle the event to be  
picked up asynchronously - but it's quite an overload considering it to be  
a workaround for simple queueing.

c) use nameko.standalone.events.event\_dispatcher and drop it right where i  
want the event to go, but then I lose all the beauty the  
providers/extensions and the mocks and testing those provide.

What would be the preferred way to go about this from namekos philosophy?

Tried something like but had no luck whatsoever.:

&nbsp;&nbsp;&nbsp;&nbsp;from nameko.messaging import Publisher, consume  
&nbsp;&nbsp;&nbsp;&nbsp;from kombu import Exchange, Queue  
&nbsp;&nbsp;&nbsp;&nbsp;ew\_exchange = Exchange('ew\_messenger',)  
&nbsp;&nbsp;&nbsp;&nbsp;ew\_sendmail\_queue =  
Queue('mailqueue',exchange=ew\_exchange,routing\_key='sendmail')

&nbsp;&nbsp;&nbsp;&nbsp;class someservice(object):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name='some'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(exchange=ew\_exchange, queue=ew\_sendmail\_queue)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def ...  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg)

&nbsp;&nbsp;&nbsp;&nbsp;class mailsender(object):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name='mailsender'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@event\_handler('ew\_messenger','mailqueue')  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def foo():  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# ...  
&nbsp;&nbsp;&nbsp;&nbsp;  
Clarity is greatly appreciated.

Thanks,  
Remco Boerma

---

<div class="post-metadata">

### Author: ![David\_Szotten](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/david_szotten/32/6_2.png) [@David\_Szotten](https://discourse.nameko.io/u/David_Szotten)
#### Post date: [February 18, 2016, 9:27am UTC](https://discourse.nameko.io/t/regular-message-queueing/122/2 "2016-02-18T09:27:09Z")

</div>

Hi Remco,

Both a) and b) seem like reasonable options to me.

"forgetting" (or ignoring) the response (which may be empty if you're  
never going to use it) seems perfectly fine.

b) might let you add some more features if you want, e.g. the email  
service's rpc call could reply with some identifier and let clients later  
enquire about the result of the send status etc, whilst internally using  
some other mechanism to delay the sending. that could itself be an async  
rpc call, an event, or some different mechanism such as an external queue  
e.g. in a db. unless your email volumes are huge you may not need to worry  
about the overhead here

Best,  
David

> **···**
>
> On Wednesday, 17 February 2016 22:48:47 UTC, remco....@gmail.com wrote:
> 
> > Hi,
> > 
> > I was searching for a way to use 'regular' queueing in nameko.  
> > It makes sense to have one service for sending mail. Using RPC from other  
> > services to this mailer service is possible but let's say i don't need the  
> > response, so why wait for an answer right? Here are a few options that came  
> > to mind:
> > 
> > a) call the rpc using async and 'forget' about the response
> > 
> > b) use RPC to call a function in the mailsender that will drop an event  
> > to itself and return (nearly) instantly and let nameko handle the event to  
> > be picked up asynchronously - but it's quite an overload considering it to  
> > be a workaround for simple queueing.
> > 
> > c) use nameko.standalone.events.event\_dispatcher and drop it right where  
> > i want the event to go, but then I lose all the beauty the  
> > providers/extensions and the mocks and testing those provide.
> > 
> > What would be the preferred way to go about this from namekos philosophy?
> > 
> > Tried something like but had no luck whatsoever.:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;from nameko.messaging import Publisher, consume  
> > &nbsp;&nbsp;&nbsp;&nbsp;from kombu import Exchange, Queue  
> > &nbsp;&nbsp;&nbsp;&nbsp;ew\_exchange = Exchange('ew\_messenger',)  
> > &nbsp;&nbsp;&nbsp;&nbsp;ew\_sendmail\_queue =  
> > Queue('mailqueue',exchange=ew\_exchange,routing\_key='sendmail')
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;class someservice(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name='some'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(exchange=ew\_exchange,  
> > queue=ew\_sendmail\_queue)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def ...  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg)
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;class mailsender(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name='mailsender'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@event\_handler('ew\_messenger','mailqueue')  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def foo():  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# ...  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > Clarity is greatly appreciated.
> > 
> > Thanks,  
> > Remco Boerma

---

<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: [February 18, 2016, 10:23am UTC](https://discourse.nameko.io/t/regular-message-queueing/122/3 "2016-02-18T10:23:59Z")

</div>

The Publisher and Consumer in nameko.messaging exist for this purpose.  
Events are a special case of "regular" messaging that uses a specific  
exchange, routing keys and queue names.

You are on the right track with the Publisher, but need to consume messages  
with the Consumer rather than an event\_handler.

# messages.py  
from kombu import Exchange, Queue  
from nameko.messaging import Publisher, consume  
from nameko.rpc import rpc

ew\_exchange = Exchange('ew\_messenger',)  
ew\_sendmail\_queue = Queue('mailqueue', exchange=ew\_exchange, routing\_key=  
'sendmail')

class SomeService(object):  
&nbsp;&nbsp;&nbsp;&nbsp;name = 'some'

&nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(exchange=ew\_exchange, queue=ew\_sendmail\_queue)

&nbsp;&nbsp;&nbsp;&nbsp;@rpc # expose with rpc so we can test it easily  
&nbsp;&nbsp;&nbsp;&nbsp;def send(self, msg):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg, routing\_key=ew\_sendmail\_queue.routing\_key)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "sent!"

class MailSender(object):  
&nbsp;&nbsp;&nbsp;&nbsp;name = 'mailsender'

&nbsp;&nbsp;&nbsp;&nbsp;@consume(ew\_sendmail\_queue)  
&nbsp;&nbsp;&nbsp;&nbsp;def send\_mail(self, msg):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("sending `{}`".format(msg))

Nameko Python 2.7.10 (default, Jul 6 2015, 15:19:48)  
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] shell on darwin  
Broker: amqp://guest:guest@localhost

> > > n.rpc.some.send("message!")

u'sent!'

(tmp-2dfbeabdba274978)Matts-13-inch-Macbook-Pro:tmp mattbennett$ nameko run  
messages  
starting services: some, mailsender  
Connected to amqp://guest:\*\*@127.0.0.1:5672//  
Connected to amqp://guest:\*\*@127.0.0.1:5672//  
sending `message!`

For this particular use-case you can make it even simpler by removing the  
ew\_exchange and using the default exchange instead -- then you'd publish  
with a routing\_key equal to the destination queue name.

Matt.

> **···**
>
> On Wednesday, February 17, 2016 at 10:48:47 PM UTC, remco....@gmail.com wrote:
> 
> > Hi,
> > 
> > I was searching for a way to use 'regular' queueing in nameko.  
> > It makes sense to have one service for sending mail. Using RPC from other  
> > services to this mailer service is possible but let's say i don't need the  
> > response, so why wait for an answer right? Here are a few options that came  
> > to mind:
> > 
> > a) call the rpc using async and 'forget' about the response
> > 
> > b) use RPC to call a function in the mailsender that will drop an event  
> > to itself and return (nearly) instantly and let nameko handle the event to  
> > be picked up asynchronously - but it's quite an overload considering it to  
> > be a workaround for simple queueing.
> > 
> > c) use nameko.standalone.events.event\_dispatcher and drop it right where  
> > i want the event to go, but then I lose all the beauty the  
> > providers/extensions and the mocks and testing those provide.
> > 
> > What would be the preferred way to go about this from namekos philosophy?
> > 
> > Tried something like but had no luck whatsoever.:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;from nameko.messaging import Publisher, consume  
> > &nbsp;&nbsp;&nbsp;&nbsp;from kombu import Exchange, Queue  
> > &nbsp;&nbsp;&nbsp;&nbsp;ew\_exchange = Exchange('ew\_messenger',)  
> > &nbsp;&nbsp;&nbsp;&nbsp;ew\_sendmail\_queue =  
> > Queue('mailqueue',exchange=ew\_exchange,routing\_key='sendmail')
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;class someservice(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name='some'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(exchange=ew\_exchange,  
> > queue=ew\_sendmail\_queue)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def ...  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg)
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;class mailsender(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name='mailsender'  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@event\_handler('ew\_messenger','mailqueue')  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def foo():  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# ...  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > Clarity is greatly appreciated.
> > 
> > Thanks,  
> > Remco Boerma

---

<div class="post-metadata">

### Author: ![Remco\_Boerma](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@Remco\_Boerma](https://discourse.nameko.io/u/Remco_Boerma)
#### Post date: [February 18, 2016, 12:50pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122/4 "2016-02-18T12:50:49Z")

</div>

Thank you David and Matt for the clarity.

@Matt, you mention:

> For this particular use-case you can make it even simpler by removing the  
> ew\_exchange and using the default exchange instead -- then you'd publish  
> with a routing\_key equal to the destination queue name.

Which would be as simple as

ew\_exchange = Exchange()

or would it require more change to the code?

Is this documented in the manual? If so I missed it about 40 times reading  
it again and again 🙂

With kind regards,  
Remco

---

<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: [February 18, 2016, 4:26pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122/5 "2016-02-18T16:26:31Z")

</div>

You don't need to specify an exchange at all. All queues are explicitly  
bound to the default exchange, and you publish to them by using the queue  
name as the routing key.

from kombu import Queue  
from nameko.messaging import Publisher, consume  
from nameko.rpc import rpc

ew\_sendmail\_queue = Queue('mailqueue')

class SomeService(object):  
&nbsp;&nbsp;&nbsp;&nbsp;name = 'some'

&nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(queue=ew\_sendmail\_queue)

&nbsp;&nbsp;&nbsp;&nbsp;@rpc # expose with rpc so we can test it easily  
&nbsp;&nbsp;&nbsp;&nbsp;def send(self, msg):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg, routing\_key="mailqueue")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "sent!"

class MailSender(object):  
&nbsp;&nbsp;&nbsp;&nbsp;name = 'mailsender'

&nbsp;&nbsp;&nbsp;&nbsp;@consume(ew\_sendmail\_queue)  
&nbsp;&nbsp;&nbsp;&nbsp;def send\_mail(self, msg):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("sending `{}`".format(msg))

The Publisher and Consumer are not mentioned in the nameko docs I'm afraid.  
The default exchange behaviour is mentioned in the RabbitMQ tutorial docs  
([https://www.rabbitmq.com/getstarted.html\](https://www.rabbitmq.com/getstarted.html%5C)), which are excellent.

> **···**
>
> On Thursday, February 18, 2016 at 12:50:49 PM UTC, remco....@gmail.com wrote:
> 
> > Thank you David and Matt for the clarity.
> > 
> > @Matt, you mention:
> > 
> > > For this particular use-case you can make it even simpler by removing the  
> > > ew\_exchange and using the default exchange instead -- then you'd publish  
> > > with a routing\_key equal to the destination queue name.
> > 
> > Which would be as simple as
> > 
> > ew\_exchange = Exchange()
> > 
> > or would it require more change to the code?
> > 
> > Is this documented in the manual? If so I missed it about 40 times reading  
> > it again and again 🙂
> > 
> > With kind regards,  
> > Remco

---

<div class="post-metadata">

### Author: ![Remco\_Boerma](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@Remco\_Boerma](https://discourse.nameko.io/u/Remco_Boerma)
#### Post date: [February 18, 2016, 6:19pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122/6 "2016-02-18T18:19:18Z")

</div>

Thanks for the headsup.

The RabbitMQ documentation is excellent. I remembered the default from  
there, but i wasn't sure if you would refer to that or another default.

I do believe the Consumer and Publisher deserve an appropriate place in the  
docs. Even though it's "simple" it's definitely something worth mentioning  
to handle more of the common scenarios.

The more I work with nameko the more I like it. Not having to handle the  
gory messaging details is a real pleasure. One thing that is bugging me a  
little though is the sending of datetime objects. I convert them to  
isoformat now. How do you go about this?

The example is really great. So simple, so effective. Thanks a bunch!  
What happens if a different routing\_key is used? What's the benefit of the  
freedom of not being forced to use the name which is already present from  
within send\_mail?

With kind regards,  
Remco

> **···**
>
> Op donderdag 18 februari 2016 17:26:32 UTC+1 schreef Matt Bennett:
> 
> > You don't need to specify an exchange at all. All queues are explicitly  
> > bound to the default exchange, and you publish to them by using the queue  
> > name as the routing key.
> > 
> > from kombu import Queue  
> > from nameko.messaging import Publisher, consume  
> > from nameko.rpc import rpc
> > 
> > ew\_sendmail\_queue = Queue('mailqueue')
> > 
> > class SomeService(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;name = 'some'
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(queue=ew\_sendmail\_queue)
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@rpc # expose with rpc so we can test it easily  
> > &nbsp;&nbsp;&nbsp;&nbsp;def send(self, msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg, routing\_key="mailqueue")  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "sent!"
> > 
> > class MailSender(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;name = 'mailsender'
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@consume(ew\_sendmail\_queue)  
> > &nbsp;&nbsp;&nbsp;&nbsp;def send\_mail(self, msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("sending `{}`".format(msg))
> > 
> > The Publisher and Consumer are not mentioned in the nameko docs I'm  
> > afraid. The default exchange behaviour is mentioned in the RabbitMQ  
> > tutorial docs ([https://www.rabbitmq.com/getstarted.html\](https://www.rabbitmq.com/getstarted.html%5C)), which are  
> > excellent.
> > 
> > On Thursday, February 18, 2016 at 12:50:49 PM UTC, remco....@gmail.com \> wrote:
> > 
> > > Thank you David and Matt for the clarity.
> > > 
> > > @Matt, you mention:
> > > 
> > > > For this particular use-case you can make it even simpler by removing  
> > > > the ew\_exchange and using the default exchange instead -- then you'd  
> > > > publish with a routing\_key equal to the destination queue name.
> > > 
> > > Which would be as simple as
> > > 
> > > ew\_exchange = Exchange()
> > > 
> > > or would it require more change to the code?
> > > 
> > > Is this documented in the manual? If so I missed it about 40 times  
> > > reading it again and again 🙂
> > > 
> > > With kind regards,  
> > > Remco

---

<div class="post-metadata">

### Author: ![Conor\_Seabrook](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/conor_seabrook/32/85_2.png) [@Conor\_Seabrook](https://discourse.nameko.io/u/Conor_Seabrook)
#### Post date: [February 22, 2016, 6:45pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122/7 "2016-02-22T18:45:55Z")

</div>

Great stuff. This is exactly what I needed!

> **···**
>
> On Thursday, February 18, 2016 at 11:26:32 AM UTC-5, Matt Bennett wrote:
> 
> > You don't need to specify an exchange at all. All queues are explicitly  
> > bound to the default exchange, and you publish to them by using the queue  
> > name as the routing key.
> > 
> > from kombu import Queue  
> > from nameko.messaging import Publisher, consume  
> > from nameko.rpc import rpc
> > 
> > ew\_sendmail\_queue = Queue('mailqueue')
> > 
> > class SomeService(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;name = 'some'
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(queue=ew\_sendmail\_queue)
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@rpc # expose with rpc so we can test it easily  
> > &nbsp;&nbsp;&nbsp;&nbsp;def send(self, msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg, routing\_key="mailqueue")  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "sent!"
> > 
> > class MailSender(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;name = 'mailsender'
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@consume(ew\_sendmail\_queue)  
> > &nbsp;&nbsp;&nbsp;&nbsp;def send\_mail(self, msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("sending `{}`".format(msg))
> > 
> > The Publisher and Consumer are not mentioned in the nameko docs I'm  
> > afraid. The default exchange behaviour is mentioned in the RabbitMQ  
> > tutorial docs ([https://www.rabbitmq.com/getstarted.html\](https://www.rabbitmq.com/getstarted.html%5C)), which are  
> > excellent.
> > 
> > On Thursday, February 18, 2016 at 12:50:49 PM UTC, remco....@gmail.com \> wrote:
> > 
> > > Thank you David and Matt for the clarity.
> > > 
> > > @Matt, you mention:
> > > 
> > > > For this particular use-case you can make it even simpler by removing  
> > > > the ew\_exchange and using the default exchange instead -- then you'd  
> > > > publish with a routing\_key equal to the destination queue name.
> > > 
> > > Which would be as simple as
> > > 
> > > ew\_exchange = Exchange()
> > > 
> > > or would it require more change to the code?
> > > 
> > > Is this documented in the manual? If so I missed it about 40 times  
> > > reading it again and again 🙂
> > > 
> > > With kind regards,  
> > > Remco

---

<div class="post-metadata">

### Author: ![Remco\_Boerma](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@Remco\_Boerma](https://discourse.nameko.io/u/Remco_Boerma)
#### Post date: [March 3, 2016, 10:05pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122/8 "2016-03-03T22:05:39Z")

</div>

How do you do this from a 'standalone' / foreign application? Any built-in  
support for that?

> **···**
>
> Op donderdag 18 februari 2016 17:26:32 UTC+1 schreef Matt Bennett:
> 
> > You don't need to specify an exchange at all. All queues are explicitly  
> > bound to the default exchange, and you publish to them by using the queue  
> > name as the routing key.
> > 
> > from kombu import Queue  
> > from nameko.messaging import Publisher, consume  
> > from nameko.rpc import rpc
> > 
> > ew\_sendmail\_queue = Queue('mailqueue')
> > 
> > class SomeService(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;name = 'some'
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(queue=ew\_sendmail\_queue)
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@rpc # expose with rpc so we can test it easily  
> > &nbsp;&nbsp;&nbsp;&nbsp;def send(self, msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg, routing\_key="mailqueue")  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "sent!"
> > 
> > class MailSender(object):  
> > &nbsp;&nbsp;&nbsp;&nbsp;name = 'mailsender'
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;@consume(ew\_sendmail\_queue)  
> > &nbsp;&nbsp;&nbsp;&nbsp;def send\_mail(self, msg):  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("sending `{}`".format(msg))
> > 
> > The Publisher and Consumer are not mentioned in the nameko docs I'm  
> > afraid. The default exchange behaviour is mentioned in the RabbitMQ  
> > tutorial docs ([https://www.rabbitmq.com/getstarted.html\](https://www.rabbitmq.com/getstarted.html%5C)), which are  
> > excellent.
> > 
> > On Thursday, February 18, 2016 at 12:50:49 PM UTC, remco....@gmail.com \> wrote:
> > 
> > > Thank you David and Matt for the clarity.
> > > 
> > > @Matt, you mention:
> > > 
> > > > For this particular use-case you can make it even simpler by removing  
> > > > the ew\_exchange and using the default exchange instead -- then you'd  
> > > > publish with a routing\_key equal to the destination queue name.
> > > 
> > > Which would be as simple as
> > > 
> > > ew\_exchange = Exchange()
> > > 
> > > or would it require more change to the code?
> > > 
> > > Is this documented in the manual? If so I missed it about 40 times  
> > > reading it again and again 🙂
> > > 
> > > With kind regards,  
> > > Remco

---

<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: [March 6, 2016, 11:58am UTC](https://discourse.nameko.io/t/regular-message-queueing/122/9 "2016-03-06T11:58:33Z")

</div>

For "regular" AMQP messaging there's nothing nameko specific, so we didn't  
bother adding anything to the nameko.standalone package. You can use any  
AMQP library to publish or consume messages. Nameko uses kombu but there  
are plenty of others.

For an example using kombu, see the nameko.standalone.events module. A  
nameko event is nothing more than a normal AMQP message with a predefined  
exchange and routing key, so you won't have to modify it much.

> **···**
>
> On Thursday, March 3, 2016 at 10:05:39 PM UTC, remco....@gmail.com wrote:
> 
> > How do you do this from a 'standalone' / foreign application? Any built-in  
> > support for that?
> > 
> > Op donderdag 18 februari 2016 17:26:32 UTC+1 schreef Matt Bennett:
> > 
> > > You don't need to specify an exchange at all. All queues are explicitly  
> > > bound to the default exchange, and you publish to them by using the queue  
> > > name as the routing key.
> > > 
> > > from kombu import Queue  
> > > from nameko.messaging import Publisher, consume  
> > > from nameko.rpc import rpc
> > > 
> > > ew\_sendmail\_queue = Queue('mailqueue')
> > > 
> > > class SomeService(object):  
> > > &nbsp;&nbsp;&nbsp;&nbsp;name = 'some'
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(queue=ew\_sendmail\_queue)
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;@rpc # expose with rpc so we can test it easily  
> > > &nbsp;&nbsp;&nbsp;&nbsp;def send(self, msg):  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg, routing\_key="mailqueue")  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "sent!"
> > > 
> > > class MailSender(object):  
> > > &nbsp;&nbsp;&nbsp;&nbsp;name = 'mailsender'
> > > 
> > > &nbsp;&nbsp;&nbsp;&nbsp;@consume(ew\_sendmail\_queue)  
> > > &nbsp;&nbsp;&nbsp;&nbsp;def send\_mail(self, msg):  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("sending `{}`".format(msg))
> > > 
> > > The Publisher and Consumer are not mentioned in the nameko docs I'm  
> > > afraid. The default exchange behaviour is mentioned in the RabbitMQ  
> > > tutorial docs ([https://www.rabbitmq.com/getstarted.html\](https://www.rabbitmq.com/getstarted.html%5C)), which are  
> > > excellent.
> > > 
> > > On Thursday, February 18, 2016 at 12:50:49 PM UTC, remco....@gmail.com \>\> wrote:
> > > 
> > > > Thank you David and Matt for the clarity.
> > > > 
> > > > @Matt, you mention:
> > > > 
> > > > > For this particular use-case you can make it even simpler by removing  
> > > > > the ew\_exchange and using the default exchange instead -- then you'd  
> > > > > publish with a routing\_key equal to the destination queue name.
> > > > 
> > > > Which would be as simple as
> > > > 
> > > > ew\_exchange = Exchange()
> > > > 
> > > > or would it require more change to the code?
> > > > 
> > > > Is this documented in the manual? If so I missed it about 40 times  
> > > > reading it again and again 🙂
> > > > 
> > > > With kind regards,  
> > > > Remco

---

<div class="post-metadata">

### Author: ![Remco\_Boerma](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@Remco\_Boerma](https://discourse.nameko.io/u/Remco_Boerma)
#### Post date: [March 10, 2016, 2:05pm UTC](https://discourse.nameko.io/t/regular-message-queueing/122/10 "2016-03-10T14:05:57Z")

</div>

Thanks. This is what I had in mind, but just thought to ask if i hadn't  
missed anything.

> **···**
>
> Op zondag 6 maart 2016 12:58:33 UTC+1 schreef Matt Bennett:
> 
> > For "regular" AMQP messaging there's nothing nameko specific, so we didn't  
> > bother adding anything to the nameko.standalone package. You can use any  
> > AMQP library to publish or consume messages. Nameko uses kombu but there  
> > are plenty of others.
> > 
> > For an example using kombu, see the nameko.standalone.events module. A  
> > nameko event is nothing more than a normal AMQP message with a predefined  
> > exchange and routing key, so you won't have to modify it much.
> > 
> > On Thursday, March 3, 2016 at 10:05:39 PM UTC, remco....@gmail.com wrote:
> > 
> > > How do you do this from a 'standalone' / foreign application? Any  
> > > built-in support for that?
> > > 
> > > Op donderdag 18 februari 2016 17:26:32 UTC+1 schreef Matt Bennett:
> > > 
> > > > You don't need to specify an exchange at all. All queues are explicitly  
> > > > bound to the default exchange, and you publish to them by using the queue  
> > > > name as the routing key.
> > > > 
> > > > from kombu import Queue  
> > > > from nameko.messaging import Publisher, consume  
> > > > from nameko.rpc import rpc
> > > > 
> > > > ew\_sendmail\_queue = Queue('mailqueue')
> > > > 
> > > > class SomeService(object):  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;name = 'some'
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;send\_mail = Publisher(queue=ew\_sendmail\_queue)
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;@rpc # expose with rpc so we can test it easily  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;def send(self, msg):  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.send\_mail(msg, routing\_key="mailqueue")  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "sent!"
> > > > 
> > > > class MailSender(object):  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;name = 'mailsender'
> > > > 
> > > > &nbsp;&nbsp;&nbsp;&nbsp;@consume(ew\_sendmail\_queue)  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;def send\_mail(self, msg):  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print("sending `{}`".format(msg))
> > > > 
> > > > The Publisher and Consumer are not mentioned in the nameko docs I'm  
> > > > afraid. The default exchange behaviour is mentioned in the RabbitMQ  
> > > > tutorial docs ([https://www.rabbitmq.com/getstarted.html\](https://www.rabbitmq.com/getstarted.html%5C)), which are  
> > > > excellent.
> > > > 
> > > > On Thursday, February 18, 2016 at 12:50:49 PM UTC, remco....@gmail.com \>\>\> wrote:
> > > > 
> > > > > Thank you David and Matt for the clarity.
> > > > > 
> > > > > @Matt, you mention:
> > > > > 
> > > > > > For this particular use-case you can make it even simpler by removing  
> > > > > > the ew\_exchange and using the default exchange instead -- then you'd  
> > > > > > publish with a routing\_key equal to the destination queue name.
> > > > > 
> > > > > Which would be as simple as
> > > > > 
> > > > > ew\_exchange = Exchange()
> > > > > 
> > > > > or would it require more change to the code?
> > > > > 
> > > > > Is this documented in the manual? If so I missed it about 40 times  
> > > > > reading it again and again 🙂
> > > > > 
> > > > > With kind regards,  
> > > > > Remco
