Interface ITransportRoutingBuilder
Fluent builder for configuring transport selection rules.
public interface ITransportRoutingBuilder
- Extension Methods
Examples
routing.Transport
.Route<OrderCreatedEvent>().To("rabbitmq") // IIntegrationEvent - OK
.Route<PaymentProcessedEvent>().To("kafka") // IIntegrationEvent - OK
.Default("local");
// The following would NOT compile:
// routing.Transport.Route<PlaceOrderCommand>().To("rabbitmq");
// Error: PlaceOrderCommand does not implement IIntegrationEvent
Remarks
Transport routing determines which message bus (e.g., "local", "rabbitmq", "kafka") should handle a given message type. This is the first tier of the two-tier routing architecture.
Rules are evaluated in order of registration with support for conditional routing and a default fallback transport.
Important: Only IIntegrationEvent types can be routed to remote transports. Commands and domain events are handled locally by design. This constraint is enforced at compile time to prevent architectural violations.
Properties
DefaultTransport
Gets the default transport name.
string? DefaultTransport { get; }
Property Value
Methods
Default(string)
Sets the default transport for messages that don't match any routing rules.
ITransportRoutingBuilder Default(string transport)
Parameters
transportstringThe default transport name (e.g., "local", "rabbitmq").
Returns
- ITransportRoutingBuilder
The builder for chaining.
Exceptions
- ArgumentException
Thrown when
transportis null or whitespace.
GetRules()
Gets all configured transport rules.
IReadOnlyList<TransportRoutingRule> GetRules()
Returns
- IReadOnlyList<TransportRoutingRule>
A read-only collection of transport routing rules.
Route<TEvent>()
Begins defining a transport routing rule for a specific integration event type.
ITransportRuleBuilder<TEvent> Route<TEvent>() where TEvent : IIntegrationEvent
Returns
- ITransportRuleBuilder<TEvent>
A rule builder for specifying the target transport.
Type Parameters
TEventThe integration event type to route. Must implement IIntegrationEvent to ensure only events designed for cross-service communication are sent to remote transports.
Remarks
Commands and domain events cannot be routed to remote transports. This is enforced at compile time through the IIntegrationEvent constraint.