Skip to main content

Introduction

AspNetRun Microservices implements two primary communication patterns for service-to-service interaction:
  1. Synchronous Communication - gRPC for real-time request/response
  2. 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
Example: Basket service calling Discount service to retrieve coupon information.

Asynchronous Communication (RabbitMQ + MassTransit)

Used when:
  • Services should be loosely coupled
  • Event-driven workflows are needed
  • Eventual consistency is acceptable
Example: Basket service publishing BasketCheckoutEvent consumed by Ordering service.

Technology Stack

ComponentTechnologyPurpose
Synchronous RPCgRPCHigh-performance binary protocol
Message BrokerRabbitMQReliable message queuing
Messaging FrameworkMassTransitAbstraction over RabbitMQ
SerializationProtocol BuffersEfficient 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 .proto files 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

Build docs developers (and LLMs) love