77use Illuminate \Contracts \Queue \Job as JobContract ;
88use Illuminate \Database \DetectsDeadlocks ;
99use Illuminate \Queue \Jobs \Job ;
10+ use Illuminate \Queue \Jobs \JobName ;
1011use Illuminate \Support \Str ;
1112use PhpAmqpLib \Channel \AMQPChannel ;
1213use PhpAmqpLib \Message \AMQPMessage ;
1314use VladimirYuldashev \LaravelQueueRabbitMQ \Queue \RabbitMQQueue ;
1415
1516class RabbitMQJob extends Job implements JobContract
1617{
17-
1818 use DetectsDeadlocks;
1919
2020 /**
@@ -30,20 +30,19 @@ class RabbitMQJob extends Job implements JobContract
3030 /**
3131 * Creates a new instance of RabbitMQJob.
3232 *
33- * @param \Illuminate\Container\Container $container
33+ * @param \Illuminate\Container\Container $container
3434 * @param \VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue $connection
35- * @param \PhpAmqpLib\Channel\AMQPChannel $channel
36- * @param string $queue
37- * @param \PhpAmqpLib\Message\AMQPMessage $message
35+ * @param \PhpAmqpLib\Channel\AMQPChannel $channel
36+ * @param string $queue
37+ * @param \PhpAmqpLib\Message\AMQPMessage $message
3838 */
3939 public function __construct (
4040 Container $ container ,
4141 RabbitMQQueue $ connection ,
4242 AMQPChannel $ channel ,
4343 $ queue ,
4444 AMQPMessage $ message
45- )
46- {
45+ ) {
4746 $ this ->container = $ container ;
4847 $ this ->connection = $ connection ;
4948 $ this ->channel = $ channel ;
@@ -53,14 +52,16 @@ public function __construct(
5352
5453 /**
5554 * Fire the job.
56- * @return void
55+ *
5756 * @throws Exception
57+ *
58+ * @return void
5859 */
5960 public function fire ()
6061 {
6162 $ payload = $ this ->payload ();
6263
63- list ($ class , $ method ) = $ this -> parseJob ($ payload ['job ' ]);
64+ list ($ class , $ method ) = JobName:: parse ($ payload ['job ' ]);
6465
6566 $ this ->instance = $ this ->resolve ($ class );
6667
@@ -73,6 +74,7 @@ public function fire()
7374 ) {
7475 sleep (2 );
7576 $ this ->fire ();
77+
7678 return ;
7779 }
7880
@@ -124,8 +126,10 @@ public function delete()
124126 * Release the job back into the queue.
125127 *
126128 * @param int $delay
127- * @return void
129+ *
128130 * @throws Exception
131+ *
132+ * @return void
129133 */
130134 public function release ($ delay = 0 )
131135 {
@@ -189,11 +193,13 @@ public function setJobId($id)
189193 }
190194
191195 /**
192- * Unserialize job
196+ * Unserialize job.
193197 *
194198 * @param array $body
195- * @return mixed
199+ *
196200 * @throws Exception
201+ *
202+ * @return mixed
197203 */
198204 private function unserialize (array $ body )
199205 {
@@ -205,11 +211,11 @@ private function unserialize(array $body)
205211 Str::contains ($ exception ->getMessage (), ['detected deadlock ' ])
206212 ) {
207213 sleep (2 );
214+
208215 return $ this ->unserialize ($ body );
209216 }
210217
211218 throw $ exception ;
212219 }
213220 }
214-
215221}
0 commit comments