Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Symfony Messenger 4.3

Symfony Messenger 4.3

Introduction to Symfony Messenger with a focus on the new features from the Symfony 4.3 release such as the new transports, retry strategies and handling failed messages.

Denis Brumann

July 11, 2019
Tweet

More Decks by Denis Brumann

Other Decks in Programming

Transcript

  1. Symfony Messenger 4.3 Symfony User Group Köln Von Thomas Wolf,

    www.foto-tw.de, CC BY-SA 3.0 de, https://commons.wikimedia.org/w/index.php?curid=62082470
  2. Bus

  3. Usage: messenger:consume [options] [--] [<receivers>...] messenger:consume-messages Arguments: receivers Names of

    the receivers/transports to consume in order of priority [default: ["async"]] Options: -l, --limit=LIMIT Limit the number of received messages -m, --memory-limit=MEMORY-LIMIT The memory limit the worker can consume -t, --time-limit=TIME-LIMIT The time limit in seconds the worker can run --sleep=SLEEP Seconds to sleep before asking for new messages after no messages were found [default: 1] -b, --bus=BUS Name of the bus to which received messages should be dispatched (if not passed, bus is determine automatically.
  4. framework: messenger: ... # default configuration retry_strategy: max_retries: 3 delay:

    1000 # delay for first retry multiplier: 2 # multiply delay with each try max_delay: 0 # service: null # id for custom RetryStrategy
  5. Which Handler processes a message? name: 'messenger.message_handler', handles: '*', #

    which message(s) to handle bus: 'event_bus', # restrict handler to specific bus method: 'handleEvent', # method to be called on handler priority: 1, # prioritize handler over others from_transport: 'async', # handle only received messages
  6. Which bus is injected into a service? framework: messenger: default_bus:

    'first_bus' buses: first_bus: middleware: - 'messenger.middleware.validation' second_bus: ...
  7. Which bus is injected into a service? services: _defaults: bind:

    $firstBus: 'first_bus' $secondBus: 'second_bus'