Skip to content

Commit

Permalink
+ Support for retries
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Mysenko committed Jun 20, 2016
1 parent 7e0ce75 commit 4c49a46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
15 changes: 5 additions & 10 deletions src/Sqs/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,12 @@ private function modifyPayload($payload, $class)
{
if (! is_array($payload)) $payload = json_decode($payload, true);

if(!array_key_exists('job', $payload) || !array_key_exists('data', $payload)){
$body = [
'job' => $class . '@handle',
'data' => json_decode($payload['Body'])
];

$body = [
'job' => $class . '@handle',
'data' => json_decode($payload['Body']),
'was_plain' => true
];

$payload['Body'] = json_encode($body);

}
$payload['Body'] = json_encode($body);

return $payload;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Sqs/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ private function getClass($queue = null)
? Config::get('sqs-plain.handlers')[$queue]
: Config::get('sqs-plain.default-handler');
}

/**
* Push a raw payload onto the queue.
*
* @param string $payload
* @param string $queue
* @param array $options
* @return mixed
* @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);

$response = $this->sqs->sendMessage(['QueueUrl' => $this->getQueue($queue), 'MessageBody' => array_key_exists('was_plain', $payload) ? json_encode($payload['data']) : json_encode($payload)]);
if (isset($payload['data']) && isset($payload['job'])) {
$payload = $payload['data'];
}

return $response->get('MessageId');
return parent::pushRaw(json_encode($payload), $queue, $options);
}
}

0 comments on commit 4c49a46

Please sign in to comment.