rabbitevents / redis-transport
Redis Streams transport for RabbitEvents
v1.0.0
2026-10-20 09:51 UTC
Requires
- php: ^8.4
- ext-json: *
- illuminate/container: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- rabbitevents/foundation: ^10.0
Requires (Dev)
- mockery/mockery: ^1.6.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.0|^12.0
- rabbitevents/listener: ^10.0
Suggests
- ext-redis: Required to connect to Redis natively via phpredis.
- predis/predis: Required if using Predis as the Redis client.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-20 10:03:03 UTC
README
Redis Streams transport driver for RabbitEvents.
This package enables RabbitEvents to publish events to and consume events from Redis Streams, providing durable event streaming, consumer groups, acknowledgement (XACK), and retry handling.
Requirements
- PHP >= 8.4
ext-redis(recommended) or compatible clientrabbitevents/foundation^10.0
Installation
composer require rabbitevents/redis-transport
Configuration
Add the redis connection to your config/rabbitevents.php:
return [ 'default' => env('RABBITEVENTS_CONNECTION', 'redis'), 'connections' => [ 'redis' => [ 'driver' => 'redis', 'host' => env('REDIS_HOST', '127.0.0.1'), 'port' => env('REDIS_PORT', 6379), 'password' => env('REDIS_PASSWORD', null), 'database' => env('REDIS_DB', 0), 'timeout' => env('REDIS_TIMEOUT', 3.0), 'stream' => env('RABBITEVENTS_REDIS_STREAM', 'events'), 'consumer' => env('RABBITEVENTS_REDIS_CONSUMER', gethostname() ?: 'default'), ], // ... ], ];
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
driver |
string |
redis |
The connection driver. |
host |
string |
127.0.0.1 |
Redis server hostname or IP. |
port |
int |
6379 |
Redis server port. |
password |
string|null |
null |
Authentication password (if configured). |
database |
int |
0 |
Redis logical database index (0-15). Default is 0. |
timeout |
float |
3.0 |
Connection timeout in seconds. |
stream |
string |
events |
The Redis Stream key name used as the event topic. |
consumer |
string |
hostname |
Unique consumer identifier within the consumer group. |
Usage
Publishing Events
Publishing events remains identical to standard RabbitEvents:
use App\Events\UserRegistered; event(new UserRegistered($user)); // or publish('user.registered', ['user_id' => $user->id]);
Listening to Events
Run the RabbitEvents worker with the Redis connection:
php artisan rabbitevents:listen --connection=redis
Or specify events directly:
php artisan rabbitevents:listen user.registered,order.* --connection=redis
Architecture & Guarantees
- Topic: a Redis Stream (
eventsby default, config keystream) that publishers append every event to. - Queue: a consumer group (
XGROUP) on the topic stream, plus the queue's own direct streamrabbitevents:queue:{queue}with a group of the same name. A worker reads both with oneXREADGROUP. - Messages for one queue (retries released by a listener, messages put back with
requeue,rabbitevents:retry) are appended to that queue's direct stream, so other consumer groups on the topic don't receive them. - Requeue: a stream entry can't be returned, so
reject($message, requeue: true)andrequeue($messages)append a copy to the direct stream and acknowledge the original. Order is kept. - Acknowledgement:
XACKin the stream the entry was read from. - Wildcards: AMQP-style patterns (
user.*,order.#); entries of other events are acknowledged and skipped.
Reliability & Failed Messages
- Failed messages: RabbitEvents 10.x moves a message that failed all its tries to
{queue}.failed. With this transport it is a queue fed only through its direct stream (rabbitevents:queue:{queue}.failed);rabbitevents:failed,retry,forgetandflushwork as with RabbitMQ. - No delayed retries: Redis Streams can't delay a delivery, so a released message is retried right away regardless of
--sleep. - Message ID & Context Propagation: RFC 4122 v4 UUID message IDs and Laravel
Contextpropagation work as with RabbitMQ. - Deduplication: transport-independent; see the optional
rabbitevents/deduplicationpackage.
License
The MIT License (MIT). Please see License File for more information.