PHP 5.5+ was required in 2.X.
The biggest change is the extraction of the PheanstalkDriver
into its own
library. Rather than composer require pmg/queue
, you'll want to require the
pheanstalk driver instead: composer require pmg/queue-pheanstalk
.
Previously you gave the consumer an instance of a MessageExector
that wrapped
up a HandlerResolver
. The point of this was to map callables to message names.
In 3.0, we replace those two things with a single MessageHandler
interface.
There are two built in: a CallableHandler
and PcntlForkingHandler
.
This was done to better reflect how PMG is using the Queue (and how we think it should be used).
use PMG\Queue as Q;
/** @var Q\Driver $driver */
$driver = createADriverSomehow();
$consumer = new Q\DefaultConsumer(
$driver,
new Q\Executor\SimpleExecutor(new Q\Resolver\MappingResolver([
'AMessageName' => function (Q\Message $msg) {
// do stuff
},
// other stuff here
]))
);
use PMG\Queue as Q;
/** @var Q\Driver $driver */
$driver = createADriverSomehow();
$consumer = new Q\DefaultConsumer(
$driver,
new Q\Handler\CallableHandler(function (Q\Message $msg) {
// see https://github.com/AgencyPMG/Queue/blob/master/examples
// for some examples of what could be here.
})
);
No problem, it was moved into its own library.
composer require pmg/queue-mapping-handler
And use it like so:
use PMG\Queue as Q;
use PMG\Queue\Handler\MappingHandler;
/** @var Q\Driver $driver */
$driver = createADriverSomehow();
$consumer = new Q\DefaultConsumer(
$driver,
MappingHandler::fromArray([
'AMessageName' => function (Q\Message $msg) {
// do stuff
},
// ...
])
);
PMG\Queue\Serializer\NativeSerializer
now requires a key argument to its
constructor that it uses to sign messages.
use PMG\Queue\Serializer\NativeSerializer;
use PMG\Queue\Serializer\SigningSerializer;
$serializer = new SigningSerializer(
new NativeSerializer(),
'your super secret key'
);
$driver = new WhateverDriver(/*...*/, $serializer);
use PMG\Queue\Serializer\NativeSerializer;
$serializer = new NativeSerializer('your super secret key');
$driver = new WhateverDriver(/*...*/, $serializer);