PMG Queue

pmg/queue is a production ready queue framework that powers many internal projects at PMG.

It’s simple and extensible a number of features we’ve found to be the most useful including automatic retries and multi-queue support.

Installation & Examples

You should require the driver library of your choice with composer rather than pmg/queue directly. If you’re planning to use beanstalkd as your backend:

composer require pmg/queue-pheanstalk:~1.0

See the core examples directory on the pheanstalk examples for some code samples on gluing everything together.

READ THIS: Glossary & Core Concepts

  • A message is a serializable object that goes into the queue for later processing.
  • A producer adds messages to the queue backend via a driver and a router.
  • A consumer pulls messages out of the queue via driver and executes them with handlers and executors.
  • A driver is PHP representation of the queue backend. There are two built in: memory and beanstalkd. Drivers implement PMG\Queue\Driver.
  • A driver is PHP representation of the queue backend. There is an in memory driver included in this library as an example (and for testing), and an implementation of a beanstalkd driver available.
  • A router looks up the correct queue name for a message based on its name.
  • An executor runs the message handler. This is a simple abstraction to allow folks to fork and run jobs if they desire.
  • A handler is a callable that does the work defined by a message.
  • handler resolvers find handlers based on the message name.
  • An envelope is used internally to wrap up messages with retry information as well as metadata specific to drivers. Users need not worry about this unless they are implementing their own driver.