Skip to main content
This guide covers all aspects of configuring SimpleMessageBus in your .NET applications, from basic setup to advanced scenarios.

Basic Configuration

1

Configure for ASP.NET Core

Configure SimpleMessageBus in your Program.cs file:
2

Configure for Console Applications

For console applications, use the generic host:

Provider-Specific Configuration

Azure Storage Queue

Amazon SQS

File System

IndexedDB (Blazor WebAssembly)

Environment-Based Configuration

Configure different providers for different environments:

Message Handler Registration

Register individual handlers explicitly:
Best for: Small projects with few handlers.

Advanced Configuration

Multiple Providers

Use different providers for different message types:

Custom Dispatcher Configuration

Configure message dispatching behavior:

Serialization Configuration

Customize JSON serialization:

Configuration Best Practices

1. Use Configuration Sections

Organize configuration in appsettings.json:

2. Environment-Specific Settings

Use different configuration files per environment:

3. Secure Configuration

Store sensitive values in Azure Key Vault or AWS Secrets Manager:

4. Configuration Validation

Validate configuration at startup:

Monitoring and Observability Configuration

Logging

Configure structured logging:

Metrics

Configure metrics collection:

Health Checks

Add health checks for message bus components:

Testing Configuration

Integration Tests

Configure for integration testing:

Unit Tests

Mock configuration for unit tests:

Troubleshooting Configuration Issues

Problem: Authentication failures or connection errorsSolutions:
  • Verify connection string format
  • Check account credentials
  • Ensure network connectivity
  • Validate queue/storage account exists
Problem: Handlers not receiving messagesSolutions:
  • Verify handler implements IMessageHandler
  • Check GetHandledMessageTypes() returns correct types
  • Ensure handler is registered in DI container
  • Verify message type matches exactly
Problem: Slow message processingSolutions:
  • Increase MaxConcurrentMessages
  • Reduce PollingInterval
  • Optimize handler performance
  • Consider batch processing

Next Steps

Testing Guide

Learn how to test your configuration

Error Handling

Implement robust error handling

Performance Guide

Optimize for production workloads

Provider Guides

Deep dive into specific providers