Skip to main content

Supported brokers

Broccoli supports multiple message brokers through feature flags:
BrokerFeatureURL SchemeStatus
Redisredisredis://✅ Stable
RabbitMQrabbitmqamqp://✅ Stable
SurrealDBsurrealdbws://, mem://✅ Stable
Kafka--🚧 Planned

How broker selection works

Broccoli automatically selects the broker based on your connection URL:
// Redis
let queue = BroccoliQueue::builder("redis://localhost:6379").build().await?;

// RabbitMQ
let queue = BroccoliQueue::builder("amqp://localhost:5672").build().await?;

// SurrealDB
let queue = BroccoliQueue::builder("ws://localhost:8000").build().await?;
You must enable the appropriate feature flag for your broker. If you use a URL scheme without the corresponding feature enabled, you’ll get a compile-time error.

Choosing a broker

Feature comparison

FeatureRedisRabbitMQSurrealDB
Connection pooling
Retry handling
Message scheduling✅ (with plugin)
Fairness queues
Management API
In-memory mode

Enabling multiple brokers

You can enable multiple brokers in your project:
[dependencies]
broccoli_queue = { version = "0.4", features = ["redis", "rabbitmq"] }
This allows your application to connect to different brokers at runtime:
async fn connect_to_broker(url: &str) -> Result<BroccoliQueue, BroccoliError> {
    BroccoliQueue::builder(url)
        .pool_connections(5)
        .build()
        .await
}

// Connect based on environment
let broker_url = std::env::var("BROKER_URL")?;
let queue = connect_to_broker(&broker_url).await?;

Connection URL formats

redis://localhost:6379
redis://user:password@localhost:6379
redis://localhost:6379/0  # database number
rediss://localhost:6379   # TLS

Broker configuration

All brokers share common configuration through the builder:
let queue = BroccoliQueue::builder("redis://localhost:6379")
    // Connection pool size
    .pool_connections(10)
    
    // Retry configuration
    .failed_message_retry_strategy(
        RetryStrategy::new()
            .with_attempts(5)
            .retry_failed(true)
    )
    
    // Enable scheduling (broker-specific behavior)
    .enable_scheduling(true)
    
    .build()
    .await?;
See the individual broker pages for broker-specific options and considerations.