happyr / simplebus-bundle
How Happyr use SimpleBus
Installs: 20 951
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.0
- happyr/mq2php-bundle: ^0.2.4
- psr/log: ~1.0
- simple-bus/asynchronous: ^2.1
- simple-bus/asynchronous-bundle: ^2.3
- simple-bus/doctrine-orm-bridge: ^4.0
- simple-bus/jms-serializer-bundle-bridge: ^2.0.2
- simple-bus/rabbitmq-bundle-bridge: ^3.1
- simple-bus/symfony-bridge: ^4.1.5
Requires (Dev)
- nyholm/symfony-bundle-test: ^1.0.2
- phpunit/phpunit: ^5.7
- simple-bus/jms-serializer-bundle-bridge: ^2.0
- symfony/symfony: ^3.0
This package is auto-updated.
Last update: 2024-10-25 08:27:53 UTC
README
This bundle includes all the nice extra features Happyr needs for their SimpleBus installation. The purpose is not to be 100% resuable and flexible. Feel free to for it and adjust it for your needs.
Installation
composer require happyr/simplebus-bundle
class AppKernel extends Kernel { public function registerBundles() { $bundles = [ // ... new Happyr\SimpleBusBundle\HappyrSimpleBusBundle(), // <-- Make sure this is before the SimpleBusBrige bundles. new Happyr\Mq2phpBundle\HappyrMq2phpBundle(), new SimpleBus\SymfonyBridge\SimpleBusCommandBusBundle(), new SimpleBus\SymfonyBridge\SimpleBusEventBusBundle(), new SimpleBus\AsynchronousBundle\SimpleBusAsynchronousBundle(), new SimpleBus\RabbitMQBundleBridge\SimpleBusRabbitMQBundleBridgeBundle(), new SimpleBus\JMSSerializerBundleBridge\SimpleBusJMSSerializerBundleBridgeBundle(), new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(), new JMS\SerializerBundle\JMSSerializerBundle(), new SimpleBus\JMSSerializerBundleBridge\SimpleBusJMSSerializerBundleBridgeBundle(), ]; // ... } // ... }
# /app/config/happyr_simplebus.yml parameters: app.command_queue: 'commands' app.event_queue: 'events' simple_bus.command_bus.logging.level: info simple_bus.event_bus.logging.level: info happyr_mq2php: enabled: true secret_key: 'CHANGE_ME' command_queue: "%app.command_queue%" event_queue: "%app.event_queue%" message_headers: fastcgi_host: "%fastcgi_host%" fastcgi_port: "%fastcgi_port%" dispatch_path: "%mq2php_dispatch_path%" command_bus: logging: ~ event_bus: logging: ~ simple_bus_rabbit_mq_bundle_bridge: commands: # this producer service will be defined by OldSoundRabbitMqBundle, # its name is old_sound_rabbit_mq.%producer_name%_producer producer_service_id: old_sound_rabbit_mq.asynchronous_commands_producer events: # this producer service will be defined by OldSoundRabbitMqBundle, # its name is old_sound_rabbit_mq.%producer_name%_producer producer_service_id: old_sound_rabbit_mq.asynchronous_events_producer simple_bus_asynchronous: events: strategy: 'predefined' old_sound_rabbit_mq: connections: default: host: "%rabbitmq_host%" port: 5672 user: 'guest' password: 'guest' vhost: '/' lazy: false connection_timeout: 3 read_write_timeout: 3 # requires php-amqplib v2.4.1+ and PHP5.4+ keepalive: false # requires php-amqplib v2.4.1+ heartbeat: 0 producers: asynchronous_commands: connection: default exchange_options: { name: '%app.command_queue%', type: "x-delayed-message", arguments: {"x-delayed-type": ["S","direct"]} } queue_options: { name: "%app.command_queue%", durable: true } asynchronous_events: connection: default exchange_options: { name: '%app.event_queue%', type: "x-delayed-message", arguments: {"x-delayed-type": ["S","direct"]} } queue_options: { name: "%app.event_queue%", durable: true }
Continue to read at Mq2phpBundle. Make sure to install the RabbitMQ extension for delayed messages.
Use
Create your messages in
src/App/Message
Command
CommandHandler
Event
EventSubscriber
And they will be auto wired and registered automatically. You may of course register them manually.
Classes & Interfaces
Be aware of the following base classes.
BaseCommandHandler
BaseEventSubscriber
implementsAutoRegisteredEventSubscriber
HandlesMessagesAsync
(For async handlers/subscribers)DelayedMessage
(For async messages with a delay)
Direct publisher
If do not want to use a queue you may use the direct publisher.
happyr_simplebus:
use_direct_publisher: true