i have this setup:
in my composer.json: "illuminate/queue": "^5.1", "pda/pheanstalk": "^3.0", "illuminate/encryption": "^5.1"
to add queues:
$queue = new Queue;
$queue->addConnection([
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
]);
$queue->setAsGlobal();
$queue->getContainer()->bind('encrypter', function () {
return new Illuminate\Encryption\Encrypter('joongo5Ie2thie8k');
});
$queue->getContainer()->bind('request', function () {
return new Illuminate\Http\Request();
});
$queue->push('SendEmail', ['foo' => 'demo']);
get the worker running:
$queue = new Queue;
$queue->addConnection([
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
]);
$queue->setAsGlobal();
$queue->getContainer()->bind('encrypter', function () {
return new Illuminate\Encryption\Encrypter('joongo5Ie2thie8k');
});
$queue->getContainer()->bind('request', function () {
return new Illuminate\Http\Request();
});
$worker = new Worker($queue->getQueueManager(), null, null);
while (true) {
// Parameters:
// 'default' - connection name
// 'default' - queue name
// delay
// time before retries
// max number of tries
$worker->pop('default', 'default', 0, 3, 1);
}
}
and important: add some class SendEmail that implements: public function fire($job, $data)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community