8. Advanced Configuration¶
Full configuration options:
- YAML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
# Default configuration for extension with alias: "sonata_notification" sonata_notification: # Other backends you can use: # # sonata.notification.backend.postpone # sonata.notification.backend.doctrine # sonata.notification.backend.rabbitmq backend: sonata.notification.backend.runtime # Example for using RabbitMQ # - { queue: myQueue, recover: true, default: false, routing_key: the_routing_key, dead_letter_exchange: 'my.dead.letter.exchange' } # - { queue: catchall, default: true } # # Example for using Doctrine # - { queue: sonata_page, types: [sonata.page.create_snapshot, sonata.page.create_snapshots] } # - { queue: catchall, default: true } queues: # The name of the queue queue: ~ # Required # Set the name of the default queue default: false # Only used by RabbitMQ # # Direct exchange with routing_key routing_key: '' # Only used by RabbitMQ # # If set to true, the consumer will respond with a `basic.recover` when an exception occurs, # otherwise it will not respond at all and the message will be unacknowledged recover: false # Only used by RabbitMQ # # If is set, failed messages will be rejected and sent to this exchange dead_letter_exchange: null # Only used by Doctrine # # Defines types handled by the message backend types: [] backends: doctrine: message_manager: sonata.notification.manager.message.default # The max age in seconds max_age: 86400 # The delay in microseconds pause: 500000 # The number of items on each iteration batch_size: 10 # Raising errors level states: in_progress: 10 error: 20 open: 100 done: 10000 rabbitmq: exchange: ~ # Required connection: host: localhost port: 5672 user: guest pass: guest vhost: guest console_url: 'http://localhost:55672/api' factory_class: \Enqueue\AmqpLib\AmqpConnectionFactory consumers: # If set to true, SwiftMailerConsumer and LoggerConsumer will be registered as services register_default: true # Listeners attached to the IterateEvent # Iterate event is thrown on each command iteration # # Iteration listener class must implement Sonata\NotificationBundle\Event\IterationListener iteration_listeners: [] class: message: App\Entity\SonataNotificationMessage admin: enabled: true message: class: Sonata\NotificationBundle\Admin\MessageAdmin controller: 'SonataNotificationBundle:MessageAdmin' translation: SonataNotificationBundle
- YAML
1 2 3 4 5 6 7 8
# config/packages/doctrine.yaml doctrine: orm: entity_managers: default: mappings: SonataNotificationBundle: ~
8.1. Changing AMQP transport¶
Sonata integrates with queue interop and by default uses enqueue/amqp-lib. Though you can pick your favorite library among:
- enqueue/amqp-ext: use EnqueueAmqpExtAmqpConnectionFactory class.
- enqueue/amqp-lib: use EnqueueAmqpLibAmqpConnectionFactory class.
- enqueue/amqp-bunny: use EnqueueAmqpBunnyAmqpConnectionFactory class.
For example if you decide to use enqueue/amqp-bunny transport, run composer require enqueue/amqp-ext:^0.8 and change factory_class option in the config:
- YAML
1 2 3 4 5 6 7
# config/packages/sonata_notification.yaml sonata_notification: backends: rabbitmq: connection: factory_class: Enqueue\AmqpExt\AmqpConnectionFactory