Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing @handle & createPayload parameter order issue #32

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/Jobs/DispatcherJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ public function __construct($data)
*/
public function getPayload()
{
if (! $this->isPlain()) {
return [
'job' => app('config')->get('sqs-plain.default-handler'),
'data' => $this->data
];
}

return $this->data;
}

Expand Down
24 changes: 5 additions & 19 deletions src/Sqs/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class Queue extends SqsQueue
* @param string $queue
* @return string
*/
protected function createPayload($job, $data = '', $queue = null)
protected function createPayload($job, $queue = null, $data = '')
{
if (!$job instanceof DispatcherJob) {
return parent::createPayload($job, $data, $queue);
return parent::createPayload($job, $queue, $data);
}

$handlerJob = $this->getClass($queue) . '@handle';
Expand All @@ -40,7 +40,8 @@ private function getClass($queue = null)
{
if (!$queue) return Config::get('sqs-plain.default-handler');

$queue = end(explode('/', $queue));
$tmpArray = explode('/', $queue);
$queue = end($tmpArray);

return (array_key_exists($queue, Config::get('sqs-plain.handlers')))
? Config::get('sqs-plain.handlers')[$queue]
Expand All @@ -60,6 +61,7 @@ public function pop($queue = null)
$response = $this->sqs->receiveMessage([
'QueueUrl' => $queue,
'AttributeNames' => ['ApproximateReceiveCount'],
'WaitTimeSeconds' => 20
]);

if (isset($response['Messages']) && count($response['Messages']) > 0) {
Expand Down Expand Up @@ -101,20 +103,4 @@ private function modifyPayload($payload, $class)
return $payload;
}

/**
* @param string $payload
* @param null $queue
* @param array $options
* @return mixed|null
*/
public function pushRaw($payload, $queue = null, array $options = [])
{
$payload = json_decode($payload, true);

if (isset($payload['data']) && isset($payload['job'])) {
$payload = $payload['data'];
}

return parent::pushRaw(json_encode($payload), $queue, $options);
}
}