Introduction
AspNetRun Microservices implements two primary communication patterns for service-to-service interaction:- Synchronous Communication - gRPC for real-time request/response
- Asynchronous Communication - RabbitMQ with MassTransit for event-driven messaging
Communication Patterns
Synchronous Communication (gRPC)
Used when:- Immediate response is required
- Strong typing and contract enforcement needed
- High performance is critical
Asynchronous Communication (RabbitMQ + MassTransit)
Used when:- Services should be loosely coupled
- Event-driven workflows are needed
- Eventual consistency is acceptable
Technology Stack
| Component | Technology | Purpose |
|---|---|---|
| Synchronous RPC | gRPC | High-performance binary protocol |
| Message Broker | RabbitMQ | Reliable message queuing |
| Messaging Framework | MassTransit | Abstraction over RabbitMQ |
| Serialization | Protocol Buffers | Efficient binary serialization for gRPC |
Message Flow Architecture
Key Design Principles
1. Service Autonomy
Each service owns its data and business logic. Communication happens only through well-defined contracts.2. Loose Coupling
Asynchronous messaging ensures services don’t need to know about each other’s implementation details.3. Resilience
- gRPC clients include retry policies and circuit breakers
- RabbitMQ provides message persistence and delivery guarantees
- MassTransit handles retries and error queues automatically
4. Contract-First Design
- gRPC uses
.protofiles for service definitions - Events are defined as shared contracts in BuildingBlocks.Messaging
Next Steps
gRPC Communication
Learn how Basket calls Discount service using gRPC
RabbitMQ Messaging
Understand asynchronous event publishing and consumption
MassTransit Configuration
Configure MassTransit for event-driven architecture
