Skip to content

Commit 653ae9c

Browse files
authored
Merge pull request vyuldashev#100 from jlozano254/master
Support for laravel 5.4
2 parents 1252d6c + 004b67f commit 653ae9c

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vladimir-yuldashev/laravel-queue-rabbitmq",
3-
"version": "5.3",
3+
"version": "5.4",
44
"description": "RabbitMQ driver for Laravel Queue",
55
"license": "MIT",
66
"authors": [
@@ -11,8 +11,8 @@
1111
],
1212
"require": {
1313
"php": ">=5.6.4",
14-
"illuminate/support": "5.3.*",
15-
"illuminate/queue": "5.3.*",
14+
"illuminate/support": "5.4.*",
15+
"illuminate/queue": "5.4.*",
1616
"php-amqplib/php-amqplib": "2.6.*"
1717
},
1818
"require-dev": {
@@ -24,5 +24,6 @@
2424
"VladimirYuldashev\\LaravelQueueRabbitMQ": "src/"
2525
}
2626
},
27-
"minimum-stability": "stable"
27+
"minimum-stability": "dev",
28+
"prefer-stable": true
2829
}

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/RabbitMQQueue.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class RabbitMQQueue extends Queue implements QueueContract
3333
/**
3434
* @var int
3535
*/
36-
private $attempts;
36+
private $retryAfter;
3737

3838
/**
3939
* @var string
@@ -42,7 +42,7 @@ class RabbitMQQueue extends Queue implements QueueContract
4242

4343
/**
4444
* @param AMQPStreamConnection $amqpConnection
45-
* @param array $config
45+
* @param array $config
4646
*/
4747
public function __construct(AMQPStreamConnection $amqpConnection, $config)
4848
{
@@ -59,7 +59,8 @@ public function __construct(AMQPStreamConnection $amqpConnection, $config)
5959
/**
6060
* Get the size of the queue.
6161
*
62-
* @param string $queue
62+
* @param string $queue
63+
*
6364
* @return int
6465
*/
6566
public function size($queue = null)
@@ -71,7 +72,7 @@ public function size($queue = null)
7172
* Push a new job onto the queue.
7273
*
7374
* @param string $job
74-
* @param mixed $data
75+
* @param mixed $data
7576
* @param string $queue
7677
*
7778
* @return bool
@@ -86,7 +87,7 @@ public function push($job, $data = '', $queue = null)
8687
*
8788
* @param string $payload
8889
* @param string $queue
89-
* @param array $options
90+
* @param array $options
9091
*
9192
* @return mixed
9293
*/
@@ -101,12 +102,12 @@ public function pushRaw($payload, $queue = null, array $options = [])
101102
}
102103

103104
$headers = [
104-
'Content-Type' => 'application/json',
105+
'Content-Type' => 'application/json',
105106
'delivery_mode' => 2,
106107
];
107108

108-
if (isset($this->attempts) === true) {
109-
$headers['application_headers'] = [self::ATTEMPT_COUNT_HEADERS_KEY => ['I', $this->attempts]];
109+
if (isset($this->retryAfter) === true) {
110+
$headers['application_headers'] = [self::ATTEMPT_COUNT_HEADERS_KEY => ['I', $this->retryAfter]];
110111
}
111112

112113
// push job to a queue
@@ -125,15 +126,15 @@ public function pushRaw($payload, $queue = null, array $options = [])
125126
* Push a new job onto the queue after a delay.
126127
*
127128
* @param \DateTime|int $delay
128-
* @param string $job
129-
* @param mixed $data
130-
* @param string $queue
129+
* @param string $job
130+
* @param mixed $data
131+
* @param string $queue
131132
*
132133
* @return mixed
133134
*/
134135
public function later($delay, $job, $data = '', $queue = null)
135136
{
136-
return $this->pushRaw($this->createPayload($job, $data), $queue, ['delay' => $this->getSeconds($delay)]);
137+
return $this->pushRaw($this->createPayload($job, $data), $queue, ['delay' => $this->secondsUntil($delay)]);
137138
}
138139

139140
/**
@@ -219,17 +220,17 @@ private function declareQueue($name)
219220
}
220221

221222
/**
222-
* @param string $destination
223+
* @param string $destination
223224
* @param DateTime|int $delay
224225
*
225226
* @return string
226227
*/
227228
private function declareDelayedQueue($destination, $delay)
228229
{
229-
$delay = $this->getSeconds($delay);
230+
$delay = $this->secondsUntil($delay);
230231
$destination = $this->getQueueName($destination);
231232
$destinationExchange = $this->configExchange['name'] ?: $destination;
232-
$name = $this->getQueueName($destination) . '_deferred_' . $delay;
233+
$name = $this->getQueueName($destination).'_deferred_'.$delay;
233234
$exchange = $this->configExchange['name'] ?: $destination;
234235

235236
// declare exchange
@@ -253,9 +254,9 @@ private function declareDelayedQueue($destination, $delay)
253254
$this->configQueue['auto_delete'],
254255
false,
255256
new AMQPTable([
256-
'x-dead-letter-exchange' => $destinationExchange,
257+
'x-dead-letter-exchange' => $destinationExchange,
257258
'x-dead-letter-routing-key' => $destination,
258-
'x-message-ttl' => $delay * 1000,
259+
'x-message-ttl' => $delay * 1000,
259260
])
260261
);
261262
}
@@ -275,7 +276,7 @@ private function declareDelayedQueue($destination, $delay)
275276
*/
276277
public function setAttempts($count)
277278
{
278-
$this->attempts = $count;
279+
$this->retryAfter = $count;
279280
}
280281

281282
/**

0 commit comments

Comments
 (0)