Skip to content
This repository was archived by the owner on Nov 9, 2020. It is now read-only.

Commit 66059ad

Browse files
committed
Make job payload compatible with redis queue
1 parent 40cd7c3 commit 66059ad

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/RemoteQueue.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use GuzzleHttp\Client;
66
use Illuminate\Queue\Queue;
7+
use Illuminate\Support\Str;
78
use Illuminate\Queue\Connectors\ConnectorInterface;
89
use Illuminate\Contracts\Queue\Queue as QueueContract;
910

@@ -113,4 +114,30 @@ protected function getQueue($queue)
113114
{
114115
return $queue ?: $this->default;
115116
}
117+
118+
/**
119+
* Create a payload string from the given job and data.
120+
*
121+
* @param string $job
122+
* @param string $queue
123+
* @param mixed $data
124+
* @return string
125+
*/
126+
protected function createPayloadArray($job, $queue, $data = '')
127+
{
128+
return array_merge(parent::createPayloadArray($job, $queue, $data), [
129+
'id' => $this->getRandomId(),
130+
'attempts' => 0,
131+
]);
132+
}
133+
134+
/**
135+
* Get a random ID string.
136+
*
137+
* @return string
138+
*/
139+
protected function getRandomId()
140+
{
141+
return Str::random(32);
142+
}
116143
}

0 commit comments

Comments
 (0)