easybib/rabbitmq-service-provider

Silex Service Provider for RabbitMQ with Symfony Event forwarding

1.0.2 2015-04-20 17:27 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:45:32 UTC


README

关于

此服务提供程序扩展了 fiunchinho/rabbitmq-service-provider 的功能

  • 将可序列化事件转发到 RabbitMQ
  • 基于 RabbitMqBundle 运行的 fabric 设置命令

用法

除了标准配置外,您还可以在 rabbit.forward.events 中指定一个 Symfony 事件名称列表,这些事件将以 rabbit.forward.producer 中的名称在生产者上发布。这些事件必须继承自 EasyBib\Silex\RabbitMq\SerializableEvent

示例配置

$app->register(new RabbitMqServiceProvider(), [
    'rabbit.connections' => [
        'default' => [
            'host'      => 'localhost',
            'port'      => 5672,
            'user'      => 'guest',
            'password'  => 'guest',
            'vhost'     => '/'
        ],
        'another' => [
            'host'      => 'another_host',
            'port'      => 5672,
            'user'      => 'guest',
            'password'  => 'guest',
            'vhost'     => '/'
        ]
    ],
    'rabbit.producers' => [
        'first_producer' => [
            'connection'        => 'another',
            'exchange_options'  => ['name' => 'a_exchange', 'type' => 'topic']
        ],
        'second_producer' => [
            'connection'        => 'default',
            'exchange_options'  => ['name' => 'a_exchange', 'type' => 'topic']
        ],
    ],
    'rabbit.consumers' => [
        'a_consumer' => [
            'connection'        => 'default',
            'exchange_options'  => ['name' => 'a_exchange','type' => 'topic'],
            'queue_options'     => ['name' => 'a_queue', 'routing_keys' => ['foo.#']],
            'callback'          => 'your_consumer_service'
        ]
    ],
    'rabbit.forward.events' => [
        'foo.my.event',
        'foo.some.event',
        'bar.the.other',
    ],
    'rabbit.forward.producer' => 'first_producer',
]);