Skip to content

Commit

Permalink
fix cron job not triggering command
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Chiriac committed Nov 25, 2021
1 parent cfcdc03 commit 78e9c72
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 78e9c72

Please sign in to comment.