A comprehensive messaging and component framework for building scalable, maintainable microservices and distributed systems in C#/.NET.
Conduit is a plugin-based messaging framework that provides:
- Component-Based Architecture: Dynamic discovery and lifecycle management of pluggable components
- CQRS Pattern: First-class support for Commands, Queries, and Events
- Pipeline Processing: Flexible behavior chain for message processing
- Multi-Transport Support: AMQP/RabbitMQ, gRPC, TCP, and Kafka adapters
- Enterprise Features: Saga orchestration, security, resilience patterns, and metrics
- Hot Reload: Dynamic component loading and unloading without restart
Conduit/
βββ src/
β βββ Conduit.Api/ # Core interfaces and contracts
β βββ Conduit.Core/ # Framework implementation
β βββ Conduit.Common/ # Shared utilities
β βββ Conduit.Pipeline/ # Pipeline framework
β βββ Conduit.Components/ # Component system
β βββ Conduit.Messaging/ # Message bus and routing
β βββ Conduit.Saga/ # Distributed transaction orchestration
β βββ Conduit.Security/ # Authentication and authorization
β βββ Conduit.Resilience/ # Circuit breakers and retry policies
β βββ Conduit.Persistence/ # Database adapters
β βββ Conduit.Serialization/ # Multi-format serialization
β βββ Conduit.Transports/ # Transport implementations
β β βββ Conduit.Transports.Core/
β β βββ Conduit.Transports.Amqp/
β β βββ Conduit.Transports.Grpc/
β β βββ Conduit.Transports.Tcp/
β βββ Conduit.Application/ # Application host
βββ tests/ # Unit and integration tests
βββ examples/ # Example implementations
βββ docker/ # Docker configuration
- .NET 8 SDK
- Docker (optional, for running infrastructure)
# Clone the repository
git clone https://github.com/conduit/conduit-dotnet.git
cd Conduit
# Build the solution
dotnet build
# Run tests
dotnet test
# Run with Docker
docker-compose up -dusing Conduit.Api;
[Component("my-component", "My Component", "1.0.0")]
public class MyComponent : IPluggableComponent
{
public string Id => "my-component";
public string Name => "My Component";
public string Version => "1.0.0";
public string Description => "A sample component";
public async Task OnAttachAsync(ComponentContext context, CancellationToken cancellationToken)
{
// Initialize component
context.Logger.LogInformation("Component attached");
}
public IEnumerable<IBehaviorContribution> ContributeBehaviors()
{
// Return behaviors to add to the pipeline
yield break;
}
public IEnumerable<MessageHandlerRegistration> RegisterHandlers()
{
// Register command, event, and query handlers
yield return MessageHandlerRegistration.ForCommand<CreateOrderCommand, CreateOrderCommandHandler>();
}
}public class CreateOrderCommand : ICommand<OrderCreatedResult>
{
public string CustomerId { get; set; }
public List<OrderItem> Items { get; set; }
}
// Send command
var result = await messageBus.SendAsync(new CreateOrderCommand
{
CustomerId = "123",
Items = new List<OrderItem> { ... }
});public class OrderCreatedEvent : IEvent
{
public string OrderId { get; set; }
public string CustomerId { get; set; }
public decimal TotalAmount { get; set; }
}
// Publish event
await messageBus.PublishAsync(new OrderCreatedEvent
{
OrderId = "456",
CustomerId = "123",
TotalAmount = 99.99m
});public class GetOrderQuery : IQuery<Order>
{
public string OrderId { get; set; }
}
// Execute query
var order = await messageBus.QueryAsync(new GetOrderQuery { OrderId = "456" });Components are the building blocks of the Conduit framework. They can:
- Contribute behaviors to the message pipeline
- Register message handlers
- Provide services to other components
- Expose features for discovery
The message pipeline processes all messages through a chain of behaviors. Components contribute behaviors that can:
- Validate messages
- Add security context
- Log and collect metrics
- Transform messages
- Handle errors
The central message bus handles:
- Command routing (one handler)
- Event publishing (multiple handlers)
- Query execution (one handler)
- Pipeline execution
- Dynamic component discovery
- Hot reload support
- Dependency management
- Isolation levels
- CQRS pattern implementation
- Request-response for commands/queries
- Pub-sub for events
- Message correlation and causation tracking
- Behavior chain pattern
- Ordered behavior placement
- Interceptors and middleware
- Conditional behavior execution
- Authentication and authorization
- Security context propagation
- Audit logging
- Encryption support
- Circuit breaker pattern
- Retry policies with backoff
- Timeout management
- Bulkhead isolation
- Metrics collection (Prometheus compatible)
- Distributed tracing support
- Structured logging
- Health checks
- Multiple database support (PostgreSQL, MongoDB, Redis)
- Caching abstraction
- Transaction management
- Repository pattern
- AMQP/RabbitMQ
- gRPC
- TCP/Sockets
- Kafka (planned)
Configuration is handled through appsettings.json:
{
"Conduit": {
"Components": {
"DiscoveryPath": "./components",
"EnableHotReload": true
},
"Messaging": {
"DefaultTimeout": 30000,
"MaxRetries": 3
},
"Transports": {
"Amqp": {
"ConnectionString": "amqp://localhost:5672"
}
}
}
}See the /examples directory for complete examples:
- OrderService: CQRS implementation with event sourcing
- NotificationService: Event-driven notifications
- GatewayService: API gateway with routing
We welcome contributions! Please see CONTRIBUTING.md for details.
This project is licensed under the Business Source License 1.1 - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: https://docs.conduit.io
This is a C# port of the original Java Conduit framework, maintaining architectural compatibility while leveraging .NET ecosystem features.