Skip to content

Commit cc7d46f

Browse files
author
Jessica Smith
committed
Update fetching of attempt counter
1 parent aa95155 commit cc7d46f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/Jobs/RabbitMQJob.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public function release($delay = 0)
9393

9494
// write attempts to job
9595
$job->attempts = $attempts + 1;
96-
$body['data']['attempts'] = $attempts + 1;
9796

9897
$data = $body['data'];
9998

@@ -112,8 +111,12 @@ public function release($delay = 0)
112111
public function attempts()
113112
{
114113
$body = json_decode($this->message->body, true);
115-
116-
return isset($body['data']['attempts']) ? (int)$body['data']['attempts'] : 0;
114+
$job = unserialize($body['data']['command']);
115+
if (is_object($job) && property_exists($job, 'attempts'))
116+
{
117+
return (int) $job->attempts;
118+
}
119+
return 0;
117120
}
118121

119122
/**

0 commit comments

Comments
 (0)