Redis Support
Ecotone support for Redis
Installation
composer require ecotone/redisModule Powered By
Enqueue solid and powerful abstraction over asynchronous queues.
Configuration
In order to use Redis Support we need to add ConnectionFactory to our Dependency Container.
# config/services.yaml
Enqueue\Redis\RedisConnectionFactory:
class: Enqueue\Redis\RedisConnectionFactory
arguments:
- "redis://localhost:6379"use Enqueue\Redis\RedisConnectionFactory;
public function register()
{
$this->app->singleton(RedisConnectionFactory::class, function () {
return new RedisConnectionFactory("redis://localhost:6379");
});
}use Enqueue\Redis\RedisConnectionFactory;
$application = EcotoneLiteApplication::boostrap(
[
RedisConnectionFactory::class => new RedisConnectionFactory("redis://localhost:6379")
]
);Message Channel
To create Message Channel, we need to create Service Context.
use Ecotone\Redis\RedisBackedMessageChannelBuilder;
class MessagingConfiguration
{
#[ServiceContext]
public function orderChannel()
{
return RedisBackedMessageChannelBuilder::create("orders");
}
}Now orders channel will be available in Messaging System.
Message Channel Configuration
Message Publisher
If you want to publish Message directly to Exchange, you may use of Publisher.
Reference name- Name under which it will be available in Dependency Container.Queue name- Name of queue where Message should be publishedDefault Conversion [Optional]- Default type, payload will be converted to.
Publisher Configuration
withAutoDeclareQueueOnSend- should Ecotone try to declare queue before sending messagewithHeaderMapper- On default headers are not send with message. You map provide mapping for headers that should be mapped toRedis Message
Message Consumer
To connect consumer directly to a Redis Queue, we need to provide Ecotone with information, how the Queue is configured.
Provides Consumer that will be registered at given name
"orders_consumer"and will be polling"orders"queue
Consumer Configuration
Last updated
Was this helpful?