SQL Server Service Broker (SSB) is a powerful messaging framework built directly into Microsoft SQL Server. It enables reliable, asynchronous communication between different databases or within the same database, allowing applications to send, receive, and process messages without blocking transactions.
At its core, Service Broker acts like a highly scalable internal message queue, providing transactional guarantees and durability. This means messages are stored safely in SQL Server tables, ensuring they are processed exactly once, even if a server or process fails.
Key Features
- Asynchronous Messaging: Applications can send messages and continue working, without waiting for the receiving process to complete.
- Reliability: Messages are persistent and only removed from queues when successfully processed.
- Transactional Support: Messages can be sent and received as part of a SQL transaction, ensuring atomicity and rollback support.
- Integrated Security: Service Broker uses built-in SQL Server security for message delivery and authentication.
Scalability and Performance
Service Broker is designed to handle large-scale enterprise workloads. Its scalability depends primarily on the underlying SQL Server instance and hardware:
- Queue size: Virtually unlimited; constrained only by disk space and SQL Server capacity.
- Message throughput: Can handle thousands to millions of messages per hour. Large enterprises regularly process millions of messages per day using Service Broker.
- Concurrent processing: Multiple services and queues can process messages in parallel, allowing horizontal scaling across CPU cores and even multiple SQL Server instances with distributed routing.
Because Service Broker is embedded in SQL Server, it benefits from all the performance and reliability optimizations of the database engine, including indexing, partitioning, and transaction logging.
How Service Broker Uses Tables
Service Broker relies heavily on internal tables to store and manage messages, queues, and routing information. Some key table types include:

| Component | Description | Example Usage |
|---|---|---|
| Services | Database entities that expose contracts and are associated with queues. A service must be linked to at least one contract to receive messages. | Creating an expenses service: CREATE SERVICE ExpensesService ON QUEUE dbo.ExpenseQueue ([DEFAULT]); |
| Contracts | Define the format of messages that a service can send or receive. The built-in [DEFAULT] contract allows for any messages. | Specifying which message types are permitted in a conversation. |
| Queues | Storage locations for messages until they are processed. Messages are routed to queues associated with services. | CREATE QUEUE dbo.ExpenseQueue; – a queue for storing expense-related messages. |
| Conversations | Communication channels between services, initiated via BEGIN DIALOG. Each conversation has a unique identifier (UNIQUEIDENTIFIER). | Starting a dialog: BEGIN DIALOG @dialog_handle FROM SERVICE Client TO SERVICE Target ON CONTRACT [DEFAULT]; |
| Message Types | Define the structure of message content (e.g., XML, binary). The built-in [DEFAULT] supports any type. | MESSAGE TYPE [DEFAULT] for simple text-based messages. |
| Activation Procedures | Stored procedures that are automatically triggered upon message arrival in a queue. | Automatic message processing without manual monitoring. |
By leveraging these tables, Service Broker ensures durable, reliable, and transactional message delivery, even in complex enterprise scenarios.
Use Cases
- Order processing systems: Asynchronous handling of orders and notifications.
- Workflow automation: Triggering background processes without slowing down the main application.
- Integration: Reliable communication between applications or microservices using SQL Server as a messaging backbone.
- High-availability scenarios: Guaranteed delivery of messages even in clustered or mirrored database environments.
Working example
Here you have working code to check all features.
https://github.com/pascalsikora/sql-service-broker
Conclusion
SQL Server Service Broker is a robust, high-performance messaging system suitable for both medium and very large-scale applications. With its asynchronous, transactional, and secure messaging capabilities, it can handle high volumes of messages reliably, making it ideal for enterprise systems that require guaranteed delivery and scalability.
