Skip to content

Commit 2f06374

Browse files
committed
- skip bad payload jobs
1 parent da17b7f commit 2f06374

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/Jobs/AMQPJob.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,11 @@ public function __construct($container, $queue, $channel, $amqpMessage)
5050
*/
5151
public function fire()
5252
{
53-
$this->resolveAndFire(json_decode($this->amqpMessage->body, true));
54-
}
55-
56-
/**
57-
* Get the raw body string for the job.
58-
*
59-
* @return string
60-
*/
61-
public function getRawBody()
62-
{
63-
return $this->amqpMessage->body;
53+
$payload = json_decode($this->amqpMessage->body, true);
54+
if (is_null($payload))
55+
$this->delete();
56+
else
57+
$this->resolveAndFire($payload);
6458
}
6559

6660
/**
@@ -75,13 +69,13 @@ public function delete()
7569
}
7670

7771
/**
78-
* Get queue name
72+
* Get the raw body string for the job.
7973
*
8074
* @return string
8175
*/
82-
public function getQueue()
76+
public function getRawBody()
8377
{
84-
return $this->queue;
78+
return $this->amqpMessage->body;
8579
}
8680

8781
/**
@@ -127,6 +121,16 @@ public function attempts()
127121
return isset($body['data']['attempts']) ? $body['data']['attempts'] : 0;
128122
}
129123

124+
/**
125+
* Get queue name
126+
*
127+
* @return string
128+
*/
129+
public function getQueue()
130+
{
131+
return $this->queue;
132+
}
133+
130134
/**
131135
* Get the job identifier.
132136
*

0 commit comments

Comments
 (0)