Overview
SurrealDB can be used as a message broker, which is useful when you already use SurrealDB in your application or need an embedded queue for testing.Installation
Enable SurrealDB support in yourCargo.toml:
Connection
WebSocket connection
In-memory (testing)
Reuse existing connection
If you already have a SurrealDB connection, you can reuse it:Starting SurrealDB
Docker
With file persistence
Features
In-memory mode
Perfect for testing and development:Message scheduling
SurrealDB supports delayed message delivery:SurrealDB data model
Broccoli stores messages in SurrealDB tables:Configuration example
Best practices
Use in-memory for tests
Use in-memory for tests
The
mem:// scheme is ideal for unit and integration tests:Reuse connections
Reuse connections
If your application already uses SurrealDB, reuse the connection:
Consider concurrency limits
Consider concurrency limits
SurrealDB may have different concurrency characteristics than dedicated message brokers. Test with your expected load.
Limitations
- No fairness queues - Disambiguator-based fairness is not supported
- No management API - Queue status monitoring is not available
- Performance - May not match dedicated brokers for high throughput
When to use SurrealDB
Good use cases:- You already use SurrealDB and want to minimize dependencies
- Testing and development with in-memory queues
- Embedded applications with moderate queue requirements
- High-throughput production workloads
- Complex routing requirements
- When you need fairness queues or management APIs