Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

SymfonyCasts

Messenger! Queue work for Later

via SymfonyCasts

Overview

Symfony's Messenger component gives you a beautiful system for designing your code around "message" objects and decoupled "handlers" that do the work!

... wait... that's not right, it's really...

Symfony's Messenger component gives you the power to execute code asynchronously via queues and workers!

Actually, it's both! Messenger is one of the newest parts of Symfony and we absolutely ❤️ it. In this tutorial, we'll create an important application that asynchronously adds our favorite cat (Ponka) to all of your favorite photos. Along the way, we'll learn to:

  • Create a messages classes
  • Add & configure "handler" classes that do the work
  • Dispatch messages through the bus
  • Configure "transports" for async messages
  • Route messages to transports
  • Execute "worker" processes that "consume" queued messages
  • Things fail!? Retry message and set up the "failure transport"
  • Middleware
  • Add & understand message stamps
  • Prioritized transports
  • A little CQRS: a Query bus
  • Testing & Dev: handling messages "sync"
  • Deployment and supervisor
  • RabbitMQ & AMQP

Let's get to work!

Syllabus

  • Installing Messenger
  • Message, Handler & the Bus
  • Doing Work in the Handler
  • Message, Handler & debug:messenger
  • Transport: Do Work Later (Async)
  • Worker Command
  • Problems with Entities in Messages
  • Passing Entity Ids inside of Messages
  • Dispatching a Message inside a Handler?
  • Partial Handler Failures & Advanced Routing
  • Envelopes & Stamps
  • Retrying on Failure
  • Retry Delay & Retry Strategy
  • The Failure Transport
  • Investigating & Retrying Failed Messages
  • Middleware
  • Tracking Messages with Middleware & a Stamp
  • Logger Channel Setup and Autowiring
  • Middleware Message Lifecycle Logging
  • High Priority Transports
  • Handling Messages Sync while Developing
  • Functional Test for the Upload Endpoint
  • Testing with the "in-memory" Transport
  • Deployment & Supervisor
  • Killing Workers Early & on Deploy
  • Events & Event Bus
  • Creating & Handling Events
  • Dispatching the Event & No Handlers
  • Messenger vs EventDispatcher
  • Doctrine Transaction & Validation Middleware
  • Event & Command Bus Organization
  • Query Bus
  • Advanced Handler Config: Handler Subscribers
  • Sending Handlers to Different Transports: from_transport
  • AMQP with RabbitMQ
  • AMQP Internals: Exchanges & Queues
  • AMQP Priority Exchange
  • Delaying in AMQP: Dead Letter Exchange
  • Exchange Routing and Binding Keys
  • Dynamic AMQP Routing Key (AmqpStamp)
  • Serializing Messages as JSON
  • JSON, Message Headers & Serializer Options
  • Setup for Messages from an Outside System
  • Transport for Consuming External Messages
  • Custom Transport Serializer
  • The Lifecycle of a Message & its Stamps
  • Graceful Failure in the Transport Serializer
  • Mapping Messages to Classes in a Transport Serializer

Taught by

Ryan Weaver

Reviews

Start your review of Messenger! Queue work for Later

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.