Skip to main content
SimpleMessageBus is built around a few core concepts that work together to provide a simple yet powerful messaging system. Understanding these concepts will help you effectively use the library in your applications.

Architecture Overview

SimpleMessageBus Architecture SimpleMessageBus follows a publisher-subscriber pattern with the following key components:
  • Messages: Data structures that carry information between components
  • Publishers: Components that send messages to a transport mechanism
  • Handlers: Components that process messages when they are received
  • Dispatchers: Components that coordinate message delivery to handlers
  • Providers: Transport-specific implementations (Azure, AWS, File System, IndexedDB)

Messages

Messages are the fundamental units of communication in SimpleMessageBus. They represent events, commands, or notifications that need to be processed.
1

Define the Message Contract

All messages must implement the IMessage interface:
2

Implement Your Message

Create a message class with the data you need to communicate:
3

Understand the Message Envelope

Internally, SimpleMessageBus wraps your messages in a MessageEnvelope that adds metadata:

Publishers

Publishers are responsible for sending messages to the underlying transport mechanism. They serialize messages and handle transport-specific details.

IMessagePublisher Interface

Usage Example

Handlers

Handlers contain the business logic for processing messages. They implement the IMessageHandler<T> interface.

IMessageHandler Interface

Handler Implementation

Dispatchers

Dispatchers coordinate the delivery of messages from the transport mechanism to the appropriate handlers. They handle deserialization, routing, and error handling.

IMessageDispatcher Interface

Dispatcher Types

Processes messages concurrently for maximum throughput:
Best for: High-throughput scenarios where message order doesn’t matter.
Processes messages sequentially to maintain order:
Best for: Scenarios where processing order must be maintained.

Queue Processors

Queue processors are provider-specific components that poll the underlying transport for new messages and forward them to dispatchers.

IQueueProcessor Interface

Provider-Specific Processors

Polls Azure Storage Queues for new messages using configurable polling intervals.Features:
  • Configurable polling intervals
  • Automatic message visibility timeout handling
  • Batch message retrieval
Long-polls Amazon SQS queues for efficient message retrieval.Features:
  • Long polling support (up to 20 seconds)
  • FIFO queue support
  • Dead letter queue integration
Watches file system directories for new message files.Features:
  • FileSystemWatcher integration
  • Automatic file cleanup
  • Error file handling
Monitors IndexedDB for new messages in Blazor WebAssembly applications.Features:
  • Browser-native storage
  • Offline-first support
  • Client-side message processing

Message Flow

Here’s how messages flow through the system:
  1. Application creates and publishes a message
  2. Publisher serializes and sends the message to the transport
  3. Transport stores the message (queue, file, database)
  4. Queue Processor retrieves the message from transport
  5. Dispatcher deserializes and routes the message
  6. Handler processes the message with business logic

Error Handling

SimpleMessageBus provides several mechanisms for handling errors:
Most providers support automatic retry with configurable policies:
Configure exponential backoff to handle transient failures gracefully.
Failed messages can be automatically moved to dead letter queues:
Isolate poison messages for later analysis and manual intervention.
Handlers should implement proper exception handling:
Distinguish between retriable transient failures and permanent business logic errors.

Next Steps

Now that you understand the core concepts, dive deeper into specific areas:

Messages

Learn about message design and best practices

Publishers

Understand publishing patterns and configuration

Handlers

Master message processing and error handling

Dispatchers

Configure message routing and concurrency