Open a command console, enter your project directory and execute:
$ composer require artox-lab/clarc-message-bus-bundleOpen a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require artox-lab/clarc-message-bus-bundleThis command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:
// config/bundles.php
return [
// ...
ArtoxLab\Bundle\ClarcMessageBusBundle\ArtoxLabClarcMessageBusBundle::class => ['all' => true],
];Configure bundle
# config/packages/artox_lab_clarc_message_bus.yaml
artox_lab_clarc_message_bus:
bus:
middleware:
add_redelivery_stamp_middleware:
retry_count: 10
Step 1: Create your event lib based on abstract-bus-event-message
Add your event lib in project via composer
Bundle uses abstract-bus-event-message as dependency. You need to configure the services for the interfaces:
# config/services.yaml
app_message_bus.producer.bus_event_message_factory:
class: YourLib\BusEventMessage\V1\BusMessageFactory
ArtoxLab\AbstractBusEventMessage\V1\BusMessageFactoryInterface: '@app_message_bus.producer.bus_event_message_factory'
app_message_bus.producer.bus_event_message:
class: YourLib\BusEventMessage\V1\BusMessage
ArtoxLab\AbstractBusEventMessage\V1\BusMessageInterface: '@app_message_bus.producer.bus_event_message'
app_message_bus.producer.bus_event:
class: YourLib\BusEventMessage\V1\Events\BaseEvent
ArtoxLab\AbstractBusEventMessage\V1\Events\EventInterface: '@app_message_bus.producer.bus_event'# config/packages/messenger.yaml
framework:
messenger:
buses:
message.bus:
middleware:
- validation
- artox_lab_clarc_message_bus.middleware.add_redelivery_stamp_middleware
transports:
example:
dsn: "%env(RABBITMQ_TRANSPORT_DSN)%"
serializer: artox_lab_clarc_message_bus.transport.bus_serializer
retry_strategy:
delay: 10000
max_retries: 10
multiplier: 1
options:
exchange:
name: "events.example"
type: "topic"
flags: 4
queues:
events:
binding_keys: [ '#' ]
routing:
'YourLib\BusEventMessage\V1\Events\ExampleEvent': [ example ]If exchange type "topic" then symfony don't create queues automatically. Configure RabbitMqBundle
# config/packages/old_sound_rabbit_mq.yaml
old_sound_rabbit_mq:
connections:
default:
url: '%env(RABBITMQ_TRANSPORT_DSN)%'
producers:
example:
connection: default
exchange_options: { name: 'events.example', type: topic, auto_delete: true, durable: true }
service_alias: exampleOpen a command console, enter your project directory and execute the following commands to create queues and setup transports:
$ php bin/console rabbitmq:setup-fabric
$ php bin/console messenger:setup-transports