# Multiple containers

**URL:** <https://discourse.nameko.io/t/multiple-containers/343>\
**Category:** Uncategorized\
**Created:** [September 18, 2018, 6:12pm UTC](https://discourse.nameko.io/t/multiple-containers/343 "2018-09-18T18:12:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrmoud](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/shrmoud/32/26_2.png) [@shrmoud](https://discourse.nameko.io/u/shrmoud)\
**Post date:** [September 18, 2018, 6:12pm UTC](https://discourse.nameko.io/t/multiple-containers/343/1 "2018-09-18T18:12:15Z")

</div>

I have a question.

I have service\_a in one container. ([https://hastebin.com/raw/ukeranusom](https://hastebin.com/raw/ukeranusom))  
i have service\_b in another container. ([https://hastebin.com/raw/bojeyakama](https://hastebin.com/raw/bojeyakama))  
both are connected to the same rabbitmq.

however, the event dispatched by service\_a is not received by service\_b in another container.

why might this happen?

---

<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:** [September 18, 2018, 9:51pm UTC](https://discourse.nameko.io/t/multiple-containers/343/2 "2018-09-18T21:51:30Z")

</div>

The two links you’ve posted here contain the same code. Please also show what `service_a` looks like.

---

<div class="post-metadata">

**Author:** ![shrmoud](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/shrmoud/32/26_2.png) [@shrmoud](https://discourse.nameko.io/u/shrmoud)\
**Post date:** [September 24, 2018, 11:16pm UTC](https://discourse.nameko.io/t/multiple-containers/343/3 "2018-09-24T23:16:12Z")

</div>

[https://hastebin.com/raw/ukeranusom](https://hastebin.com/raw/ukeranusom)

import os  
import datetime  
import json  
import uuid  
from entrypoints import http  
from nameko.events import EventDispatcher  
from nameko.events import event\_handler  
from nameko.events import SINGLETON  
from werkzeug.wrappers import Response

class ServiceA(object):

```
name = 'service_a'
event_dispatcher = EventDispatcher()
seen_before = False

@http('GET', '/start')
def start_service(self, request):
    job_id = str(uuid.uuid4())
    self.event_dispatcher('ping', {'job_id': job_id})
    return Response(json.dumps({
        'job_id': job_id}),
        mimetype='application/json'
    )

@event_handler("service_b", "pong", handler_type=SINGLETON)
def send_message(self, payload):
    if ServiceA.seen_before:
        print("Message is already received. Skipping Processing at time {}".format(datetime.datetime.utcnow()))
    else:
        print("First message received from service_b at time {}".format(datetime.datetime.utcnow()))
        ServiceA.seen_before = True
```

---

<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:** [September 26, 2018, 2:02pm UTC](https://discourse.nameko.io/t/multiple-containers/343/4 "2018-09-26T14:02:10Z")

</div>

I can’t reproduce the problem you describe here.

I copied both of your modules into one called `services.py` and ran it. The only change I made was to correct the import of the `http` entrypoint.

I curled `/start` and it behaves as I’d expect:

```auto
$ nameko run services
starting services: service_a, service_b
Connected to amqp://guest:**@127.0.0.1:5672//
Connected to amqp://guest:**@127.0.0.1:5672//

127.0.0.1 - - [26/Sep/2018 14:51:28] "GET /start HTTP/1.1" 200 158 0.030309
pong from service_b with job_id 4b05fed6-a9f7-4aad-b950-2f2341922a75 at time 2018-09-26 13:51:28.020868 with app id NOT_FOUND
First message received from service_b at time 2018-09-26 13:51:28.033819
127.0.0.1 - - [26/Sep/2018 14:51:43] "GET /start HTTP/1.1" 200 158 0.006611
pong from service_b with job_id 9c64ea20-4352-4cad-a922-59587e1a35ec at time 2018-09-26 13:51:43.190117 with app id NOT_FOUND

```

Are you expecting it to do something else instead?

Also I just wanted to check that your definitely mean to be using the `SINGLETON` event hander type? `SINGLETON` is unusual and perhaps not doing what you’d expect (although it makes no difference if you only have one service)
