}); // END BOOTSTRAP--------------------------------------------------------------- $app->get('/sync', function () use($queue) { $queue->addConnection(['driver' => 'sync']); Queue::push('doThing', array('string' => 'sync-' . date('r'))); echo 'Pushed an instance of doThing to sync driver.'; }); $app->get('/ironio/add', function () use($queue) { $queue->getContainer()->bind('request', function () { return new Illuminate\Http\Request(); }); $queue->getContainer()->bind('IronMQ', function () { return new IronMQ(); }); $queue->addConnection(['driver' => 'iron', 'project' => 'your-project-id', 'token' => 'your-token', 'queue' => 'illuminate-test', 'encrypt' => true]); Queue::push('doThing', array('string' => 'iron-' . date('r'))); echo 'Pushed an instance of doThing to iron.io.'; }); $app->get('/ironio/work/worker', function () use($queue) { $queue->getContainer()->bind('request', function () { return new Illuminate\Http\Request(); }); $queue->getContainer()->bind('IronMQ', function () { return new IronMQ(); }); $queue->addConnection(['driver' => 'iron', 'project' => 'your-project-id', 'token' => 'your-token', 'queue' => 'illuminate-test', 'encrypt' => true]); $worker = new \Illuminate\Queue\Worker($queue->getQueueManager()); // Params list for 'pop': // * Name of the connection to use--you can define a unique connection name by passing a second parameter to addConnection above // * Name of the queue to use--this is the value for the 'queue' key in addConnection // * Number of seconds to delay a job if it fails
/** * Push new job to queue if this job is not exist * * @author Virchenko Maksim <*****@*****.**> * @param mixed $handler * @param array $data * @param string $queue * @param string $connection */ public function pushUnique($handler, $data = [], $queue = 'default', $connection = 'default') { if (false === Manager::connection($connection)->exists($handler, $data, $queue)) { Manager::push($handler, $data, $queue, $connection); } }