artox-lab / clarc-message-bus-bundle
Message bus adapter for Artox Lab CLARC bundle
Installs: 1 170
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.3
- ext-json: *
- artox-lab/abstract-bus-event-message: 1.0.0
- symfony/framework-bundle: ^5.0
- symfony/messenger: ^5.0
- symfony/validator: ^5.0
Requires (Dev)
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-10-28 19:21:35 UTC
README
Installation
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
$ composer require artox-lab/clarc-message-bus-bundle
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open 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-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
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], ];
Step 3: Configuration
Configure bundle
# config/packages/artox_lab_clarc_message_bus.yaml artox_lab_clarc_message_bus: bus: middleware: add_redelivery_stamp_middleware: retry_count: 10
Usage
Step 1: Create your event lib based on abstract-bus-event-message
Add your event lib in project via composer
Step 2: Configuring Services in the Container
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'
Step 3: Configure symfony/messenger
# 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 ]
Exchange type "topic"
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: example
Open 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