2017 © Pedro Peláez
 

library queue-pheanstalk

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

image

pmg/queue-pheanstalk

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

  • Thursday, August 31, 2017
  • by chrisguitarguy
  • Repository
  • 7 Watchers
  • 3 Stars
  • 14,501 Installations
  • PHP
  • 0 Dependents
  • 2 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 14 % Grown

The README.md

pmg/queue-pheanstalk

A driver for pmg/queue backed by Pheanstalk and Beanstalkd., (*1)

See the pmg/queue readme for the documentation of how the queue system as a whole works., (*2)

See the examples directory for examples of how to glue everything together., (*3)

Quick Example

Pheanstalk is a PHP library for interacting with Beanstalkd. PheanstalkDriver lets you take advantage of Beanstalkd as a queue backend., (*4)

use Pheanstalk\Pheanstalk;
use PMG\Queue\DefaultConsumer;
use PMG\Queue\Driver\PheanstalkDriver;
use PMG\Queue\Serializer\NativeSerializer;
use PMG\Queue\Serializer\SigningSerializer;

// ...

$serilizer = new NativeSerializer('this is the secret key');

$driver = new PheanstalkDriver(new \Pheanstalk\Pheanstalk('localhost'), $serializer, [
    // how long easy message has to execute in seconds
    'ttr'               => 100,

    // the "priority" of the message. High priority messages are
    // consumed first.
    'priority'          => 1024,

    // The delay between inserting the message and when it
    // becomes available for consumption
    'delay'             => 0,

    // The ttr for retries jobs
    'retry-ttr'         => 100,

    // the priority for retried jobs
    'retry-priority'    => 1024,

    // When jobs fail, they are "burieds" in beanstalkd with this priority
    'fail-priority'     => 1024,

    // A call to `dequeue` blocks for this number of seconds. A zero or
    // falsy value will block until a job becomes available
    'reserve-timeout'   => 10,
]);

// $handler instanceof PMG\Queue\MessageHandler
$consumer = new DefaultConsumer($driver, $handler);

Dealing with Failed Messages

By default, PheanstalkDriver will bury any message passed to PheanstalkDriver::fail. This is, generally, a good thing if there are no other accountability measures around your queue system., (*5)

That said, pmg/queue does nothing for you regarding kicking jobs back to a ready state. If there are other accountability measures around your queue implementation and you'd rather just delete failed messages after they've been retried, use a different FailureStrategy., (*6)

use Pheanstalk\Pheanstalk;
use PMG\Queue\DefaultConsumer;
use PMG\Queue\Driver\PheanstalkDriver;
use PMG\Queue\Driver\Pheanstalk\DeleteFailureStrategy;
use PMG\Queue\Serializer\NativeSerializer;

// ...

$serilizer = new NativeSerializer('this is the secret key');
$failureStrategy = new DeleteFailureStrategy();

$driver = new PheanstalkDriver(new \Pheanstalk\Pheanstalk('localhost'), $serializer, [
    // as above
], $failureStrategy);

// $handler instanceof PMG\Queue\MessageHandler
$consumer = new DefaultConsumer($driver, $handler);

Feel free to implement PMG\Queue\Driver\Pheanstalk\FailureStrategy if a different solution is needed., (*7)

The Versions

31/08 2017

dev-master

9999999-dev

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

31/08 2017

2.0.0

2.0.0.0

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

31/08 2017

dev-version-2

dev-version-2

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

17/10 2016

1.1.0

1.1.0.0

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

17/10 2016

dev-version-1

dev-version-1

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

26/08 2016

1.0.0

1.0.0.0

A pmg/queue driver implementation for Pheanstalk and Beanstalkd

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires