File tree Expand file tree Collapse file tree 3 files changed +62
-2
lines changed Expand file tree Collapse file tree 3 files changed +62
-2
lines changed Original file line number Diff line number Diff line change 3434 },
3535 "extra" : {
3636 "branch-alias" : {
37- "dev-master" : " 13.51 -dev"
37+ "dev-master" : " 13.52 -dev"
3838 },
3939 "laravel" : {
4040 "providers" : [
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace VladimirYuldashev \LaravelQueueRabbitMQ \Queue \Jobs ;
4+
5+ use Illuminate \Contracts \Encryption \Encrypter ;
6+ use Illuminate \Queue \Jobs \JobName ;
7+ use VladimirYuldashev \LaravelQueueRabbitMQ \Queue \Jobs \RabbitMQJob as BaseJob ;
8+
9+ /**
10+ * SQS Job wrapper for RabbitMQ
11+ */
12+ class RabbitMQJobBatchable extends BaseJob
13+ {
14+ /**
15+ * Fire the job.
16+ *
17+ * @return void
18+ */
19+ public function fire ()
20+ {
21+ $ payload = $ this ->payload ();
22+
23+ [$ class , $ method ] = JobName::parse ($ payload ['job ' ]);
24+
25+ ($ this ->instance = $ this ->resolve ($ class ))->{$ method }($ this , $ payload ['data ' ]);
26+ }
27+
28+ /**
29+ * Returns target class name
30+ *
31+ * @return mixed
32+ */
33+ public function getPayloadClass (): string
34+ {
35+ $ payload = $ this ->payload ();
36+
37+ return $ payload ['data ' ]['commandName ' ];
38+ }
39+
40+ /**
41+ * @return object
42+ * @throws \RuntimeException
43+ */
44+ public function getPayloadData (): object
45+ {
46+ $ payload = $ this ->payload ();
47+
48+ $ data = $ payload ['data ' ];
49+
50+ if (str_starts_with ($ data ['command ' ], 'O: ' )) {
51+ return unserialize ($ data ['command ' ]);
52+ }
53+
54+ if ($ this ->container ->bound (Encrypter::class)) {
55+ return unserialize ($ this ->container [Encrypter::class]->decrypt ($ data ['command ' ]));
56+ }
57+
58+ throw new \RuntimeException ('Unable to extract job data. ' );
59+ }
60+ }
Original file line number Diff line number Diff line change 11<?php
22
3- namespace VladimirYuldashev \LaravelQueueRabbitMQ \Queue \ Jobs ;
3+ namespace VladimirYuldashev \LaravelQueueRabbitMQ \Queue ;
44
55use PhpAmqpLib \Connection \AbstractConnection ;
66use VladimirYuldashev \LaravelQueueRabbitMQ \Queue \RabbitMQQueue as BaseRabbitMQQueue ;
You can’t perform that action at this time.
0 commit comments