> For the complete documentation index, see [llms.txt](https://docs.ecotone.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecotone.tech/solutions/microservice-communication.md).

# Microservice Communication

How to build reliable microservice communication in PHP with Ecotone Distributed Bus

## The Problem You Recognize

Your monolith is splitting into services. Or you already have multiple services and they need to talk to each other.

The current approach: HTTP calls between services. When Service B is down, Service A fails too. You've built custom retry logic, custom serialization, and custom routing for each service pair. There's no guaranteed delivery — if a request fails, the data is lost unless you built a custom retry mechanism.

The symptoms:

* **Cascading failures** — one service going down takes others with it
* **Custom glue code** per service pair — serialization, routing, error handling
* **No event sharing** — services can't subscribe to each other's events without point-to-point integrations
* **Broker lock-in** — switching from RabbitMQ to SQS means rewriting integration code

## What the Industry Calls It

**Distributed Messaging** — services communicate through a message broker with guaranteed delivery, event sharing, and transport abstraction.

## How Ecotone Solves It

Ecotone's Distributed Bus lets services send commands and publish events to each other through message brokers. Your application code stays the same — Ecotone handles routing, serialization, and delivery:

```php
// Service A: Send a command to Service B
$distributedBus->sendCommand(
    targetServiceName: "order-service",
    command: new PlaceOrder($orderId, $items),
);
```

```php
// Service B: Handle commands from other services — same as local handlers
#[Distributed]
#[CommandHandler]
public function placeOrder(PlaceOrder $command): void
{
    // This handler receives commands from any service
}
```

Supports **RabbitMQ, Amazon SQS, Redis, and Kafka** — swap transports without changing application code.

## Next Steps

* [Distributed Bus](/modelling/microservices-php/distributed-bus.md) — Cross-service messaging
* [Message Consumer](/modelling/microservices-php/message-consumer.md) — Consuming from external sources
* [Message Publisher](/modelling/microservices-php/message-publisher.md) — Publishing to external targets

{% hint style="success" %}
**As You Scale:** Ecotone Enterprise adds [Distributed Bus with Service Map](/modelling/microservices-php/distributed-bus/distributed-bus-with-service-map.md) — a topology-aware distributed bus that supports multiple brokers in a single topology, automatic routing, and cross-framework integration.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ecotone.tech/solutions/microservice-communication.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
