# Rpc over 2 machines/cards running rabbitmq

**URL:** <https://discourse.nameko.io/t/rpc-over-2-machines-cards-running-rabbitmq/454>\
**Category:** Uncategorized\
**Created:** [June 14, 2019, 12:36am UTC](https://discourse.nameko.io/t/rpc-over-2-machines-cards-running-rabbitmq/454 "2019-06-14T00:36:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maddypj](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@maddypj](https://discourse.nameko.io/u/maddypj)\
**Post date:** [June 14, 2019, 12:36am UTC](https://discourse.nameko.io/t/rpc-over-2-machines-cards-running-rabbitmq/454/1 "2019-06-14T00:36:32Z")

</div>

Is there any way to have rpc between 2 services sitting on different machines?  
Trying to simulate this by having nameko service on one machine and nameko shell on another.  
nameko shell is not able to complete the call as it does not recognize the service.

Tried to create a rabbitmq shovel between the 2 machines. Still service is not recognized.  
Does nameko support this usecase?

Example  
test\_service running on machine 1 with ip1  
another\_service Running on machine 2 with ip2  
Intention is to call test\_service from another\_service

```
from nameko.rpc import rpc, RpcProxy
class TestService1:
    name = "test_service"

    # we depend on the RPC interface of "another_service"
    other_rpc = RpcProxy("another_service")

    @rpc # `method` is exposed over RPC
    def testmethod(self):
        # application logic goes here
        print("hello world!!")

class TestService2:
    name = "another_service"

    # we depend on the RPC interface of "test_service"
    other_rpc = RpcProxy("test_service")

    @rpc # `othermethod` is exposed over RPC
    def othermethod(self):
        # application logic goes here
        print("hello world peer!!")
```

---

<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:** [June 14, 2019, 6:56am UTC](https://discourse.nameko.io/t/rpc-over-2-machines-cards-running-rabbitmq/454/2 "2019-06-14T06:56:03Z")

</div>

This is very much the normal usecase for RPC. You just need to point both services at the same RabbitMQ broker, which can be on either machine or a different one.

Add a config file with the broker URI:

```auto
# config.yaml
AMQP_URI: amqp://<rabbitmq-ip>:5672/

```

Then this on each machine:

```auto
nameko run <yourservice> --config config.yaml

```

---

<div class="post-metadata">

**Author:** ![Jakub\_Borys](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/jakub_borys/32/7_2.png) [@Jakub\_Borys](https://discourse.nameko.io/u/Jakub_Borys)\
**Post date:** [June 14, 2019, 4:44pm UTC](https://discourse.nameko.io/t/rpc-over-2-machines-cards-running-rabbitmq/454/3 "2019-06-14T16:44:18Z")

</div>

Hi @maddypj,

You should use [RabbitMQ clustering](https://www.rabbitmq.com/clustering.html) and not shovel between your rabbit nodes. Shovel should only be used to copy messages from one cluster to another, Nameko RPC will not work over it.

---

<div class="post-metadata">

**Author:** ![maddypj](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@maddypj](https://discourse.nameko.io/u/maddypj)\
**Post date:** [June 17, 2019, 11:03pm UTC](https://discourse.nameko.io/t/rpc-over-2-machines-cards-running-rabbitmq/454/4 "2019-06-17T23:03:17Z")

</div>

Thank you for your response! In my case there are 2 rabbitmq brokers, one for machine 1 and another for machine 2. Machine 2 is for HA and can come and go anytime.

I was thinking if I give 2 separate brokers in AMQP URI, kombu will round robbin and will be able to find the service. But that does not seem to be the case. Is that possible?  
Talking between services on one broker with another?  
If first broker is reachable, and the service is not found on it the second broker wont be tried?

@Jakub, Thank you for pointing at clusters. By clustering, we create a single broker across cluster but for my application, it may not have LAN like latency. I was more interested in looking at the Federation / Shovel
