Skip to content

Commit

Permalink
Merge pull request #32 from joblocal/bugfix/fix-handler-for-messages-…
Browse files Browse the repository at this point in the history
…triggering-jobs-directly

fix cron job not triggering command
  • Loading branch information
vixone authored Nov 25, 2021
2 parents cfcdc03 + 78e9c72 commit fb12527
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Queue/SqsSnsQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function pop($queue = null)
]);

if (is_array($response['Messages']) && count($response['Messages']) > 0) {
if ($this->routeExists($response['Messages'][0])) {
if ($this->routeExists($response['Messages'][0]) || $this->classExists($response['Messages'][0])) {
return new SqsSnsJob(
$this->container,
$this->sqs,
Expand All @@ -74,4 +74,18 @@ protected function routeExists(array $message)

return isset($body['Subject']) && array_key_exists($body['Subject'], $this->routes);
}

/**
* Check if the job class
* you're trying to trigger exists.
*
* @param array $message
* @return bool
*/
protected function classExists(array $message)
{
$body = json_decode($message['Body'], true);

return isset($body['data']['comandName']) && class_exists($body['data']['commandName']);
}
}

0 comments on commit fb12527

Please sign in to comment.