@@ -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