I have developed a modular system based on MicroServices, that can be deployed in one or different machines. Each MicroService actually is a package, and communicate to other MSs sending AMQP messages. In this way each server can specify which MicroService to deploy, installing the relative package. So there is a MicroService that exposes http REST API, and asks reqs to other MicroServices by AMQP messages.
This is an example: each square is a server. Each server can deploy one or MicroServices. So there is one MS listening for http reqs, that sends requests through CloudAMQP channels to other MSs.
+=============+
| MSs |
| - AUTHORIZE |
amqp | - LOG |<---
+=========+---------->+=============+ |
http:// ==>| MS | |
|REST_API | | amqp
+=========+---------->+=============+ |
amqp | MS |<---
| - REPORT |
+=============+
Now, the problem is that also MSs in the same server, exchange amqp messages through the channel, as if they were deployed in different servers. This could be not a problem, but consumes credits on CloudAMQP.
Looking at the example above, a user tries lo login, making a POST on MS_REST_API. This Ms send an amqp message to MS_AUTHORIZE that, in turn, sends an amqp message to MS_LOG to log the event.
Any idea on simulating sending amqp messages, without using CloudAMQP but something local, for MSs deployed on the same machine?
I would advise you against trying to optimize a local-service path unless there is some huge factor you haven't described above. The complexity and opportunity for errors go way up if you try this. Consider, for example, a service that needs to interact with services both local and on other nodes.
If there is a reason to change your approach, I'd recommend looking at something like Apache Qpid Dispatch Router that knows where the applications are and can route them.