Skip to content

Transports Overview

quyvu edited this page Oct 14, 2026 · 4 revisions

Message Transports

Connect your microservices using various messaging transports for distributed data mapping and real-time communication.

What are Transports?

In a microservices architecture, your entities are distributed across different services. FxMap uses message transports to fetch data from remote services seamlessly, making it feel like everything is local.

How It Works

// Define a distributed key contract (shared between services)
public class UserDistributedKey : IDistributedKey { }
 
// Provider side: configure entity via FluentAPI
public class UserConfig : EntityConfigureOf<User>
{
    protected override void Configure()
    {
        Id(x => x.Id);
        DefaultProperty(x => x.Name);
        UseDistributedKey<UserDistributedKey>();
    }
}
 
// Consumer side: declare a profile for your DTO
public class OrderResponseProfile : ProfileOf<OrderResponse>
{
    protected override void Configure()
    {
        UseDistributedKey<UserDistributedKey>()
            .Of(x => x.UserId)
            .For(x => x.UserName)
            .For(x => x.UserEmail, "Email");
    }
}
 
// Behind the scenes:
// 1. FxMap resolves the profile and distributed key
// 2. Sends a message via configured transport (RabbitMQ, gRPC, etc.)
// 3. Remote service processes request and returns data
// 4. FxMap maps the response to your DTO

Available Transports

RabbitMQ

Popular AMQP message broker with robust routing and reliability features.

NATS

High-performance, cloud-native messaging system with simplicity at its core.

Apache Kafka

Distributed event streaming platform for high-throughput, fault-tolerant messaging.

gRPC

High-performance RPC framework using HTTP/2 and Protocol Buffers.

Azure Service Bus

Enterprise-grade cloud messaging service with advanced features.

AWS SQS

Fully managed message queuing service with AWS infrastructure.

Configuration Pattern

All transports are configured within the AddFxMap configuration block:

builder.Services.AddFxMap(cfg =>
{
    // Register entity configs (service that owns data) and profiles (service that maps DTOs)
    cfg.AddEntitiesFromAssemblyContaining<SomeEntityAssemblyMarker>();
 
    // Configure transport (examples below)
    cfg.AddRabbitMq(config => config.Host("localhost", "/"));
    // OR
    cfg.AddNats(c => c.NatsOpts(opts => opts.Url = "nats://localhost:4222"));
    // OR
    cfg.AddKafka(c => c.Host("localhost:9092"));
    // OR
    cfg.AddGrpcClients(c => c.AddGrpcHosts("http://localhost:5001"));
    // OR
    cfg.AddAzureServiceBus(c => c.Host("Endpoint=sb://..."));
    // OR
    cfg.AddSqs(sqs => sqs.Region(RegionEndpoint.USEast1));
});

Key Features

Automatic Service Discovery

FxMap automatically routes requests to the correct service based on the distributed keys in your entity configs and profiles.

Request Batching

Multiple requests for the same entity type are automatically batched into a single transport call for optimal performance.

The Same Code on Every Transport

Profiles and entity configs do not change when you switch the transport: only the registration call changes.

Retry and Supervision

A configurable retry policy for a failed request, and a supervisor with a circuit breaker that restarts a failing server on the brokered transports.


Source: https://fxmapper.net/docs/transports/ — the website is always the most up to date version.

Clone this wiki locally