Skip to content

Commit 8a15d40

Browse files
SWR-15367
1 parent 8bb696c commit 8a15d40

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"extra": {
3636
"branch-alias": {
37-
"dev-master": "13.51-dev"
37+
"dev-master": "13.52-dev"
3838
},
3939
"laravel": {
4040
"providers": [
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
}

src/Queue/Jobs/RabbitMQQueueBatchable.php renamed to src/Queue/RabbitMQQueueBatchable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs;
3+
namespace VladimirYuldashev\LaravelQueueRabbitMQ\Queue;
44

55
use PhpAmqpLib\Connection\AbstractConnection;
66
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue as BaseRabbitMQQueue;

0 commit comments

Comments
 (0)