Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit 66064c9

Browse files
committed
Various fixes
1 parent e1a4922 commit 66064c9

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/AsyncQueue.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
namespace Barryvdh\Queue;
33

4+
use Illuminate\Database\Connection;
45
use Illuminate\Queue\DatabaseQueue;
6+
use Illuminate\Queue\DatabaseQueue\DatabaseJob;
57

68
class AsyncQueue extends DatabaseQueue
79
{
@@ -99,7 +101,7 @@ public function release($queue, $job, $delay)
99101
* @param string|null $queue
100102
* @return \StdClass|null
101103
*/
102-
protected function getJobFromId($queue, $id)
104+
public function getJobFromId($queue, $id)
103105
{
104106
$this->database->beginTransaction();
105107
$job = $this->database->table($this->table)
@@ -142,13 +144,14 @@ public function startProcess($queue, $id)
142144
*/
143145
protected function getCommand($queue, $id)
144146
{
147+
$connection = null;
145148
$cmd = '%s artisan queue:async %d %d --env=%s --queue=%s';
146149
$cmd = $this->getBackgroundCommand($cmd);
147150

148151
$binary = $this->getPhpBinary();
149152
$environment = $this->container->environment();
150153

151-
return sprintf($cmd, $binary, $jobId, $environment, $queue);
154+
return sprintf($cmd, $binary, $id, $connection, $environment, $queue);
152155
}
153156

154157
/**
@@ -158,7 +161,7 @@ protected function getCommand($queue, $id)
158161
*/
159162
protected function getPhpBinary()
160163
{
161-
$path = escapeshellarg($thisbinary);
164+
$path = escapeshellarg($this->binary);
162165
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
163166
$path = escapeshellarg($path);
164167
}

src/AsyncServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function register()
4646
protected function registerAsyncCommand()
4747
{
4848
$this->app->singleton('command.queue.async', function () {
49-
return new AsyncCommand($this->app['command.queue.work']);
49+
return new AsyncCommand($this->app['queue.worker']);
5050
});
5151
}
5252

src/Connectors/AsyncConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Barryvdh\Queue\AsyncQueue;
66
use Illuminate\Queue\Connectors\DatabaseConnector;
77

8-
class AsyncConnector implements DatabaseConnector
8+
class AsyncConnector extends DatabaseConnector
99
{
1010

1111
/**

src/Console/AsyncCommand.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,29 @@ public function __construct(Worker $worker)
5050
public function fire()
5151
{
5252
$queue = $this->option('queue');
53+
54+
5355
$id = $this->argument('id');
5456
$connection = $this->argument('connection');
57+
$delay = $this->option('delay');
5558
$tries = $this->option('tries');
5659

5760
$this->processJob(
58-
$connection, $queue, $delay, $tries
61+
$connection, $queue, $id, $delay, $tries
5962
);
6063
}
6164

65+
6266
/**
6367
* Process the job
6468
*
6569
*/
66-
protected function processJob($connectionName, $queue, $delay, $maxTries)
70+
protected function processJob($connectionName, $queue, $id, $delay, $maxTries)
6771
{
6872
$connection = $this->worker->getManager()->connection($connectionName);
6973

70-
$job = $this->queue->getJobFromId($queue, $id);
74+
$job = $connection->getJobFromId($queue, $id);
75+
7176
// If we're able to pull a job off of the stack, we will process it and
7277
// then immediately return back out. If there is no job on the queue
7378
// we will "sleep" the worker for the specified number of seconds.
@@ -107,6 +112,8 @@ protected function getOptions()
107112
array('queue', null, InputOption::VALUE_OPTIONAL, 'The queue name', null),
108113

109114
array('delay', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0),
115+
116+
array('tries', null, InputOption::VALUE_OPTIONAL, 'Number of times to attempt a job before logging it failed', 0),
110117
);
111118
}
112119
}

0 commit comments

Comments
 (0)