From 78e9c72b758ab78a34617f6adee501f1124d53aa Mon Sep 17 00:00:00 2001 From: Victor Chiriac Date: Thu, 25 Nov 2021 12:06:25 +0100 Subject: [PATCH] fix cron job not triggering command --- src/Queue/SqsSnsQueue.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Queue/SqsSnsQueue.php b/src/Queue/SqsSnsQueue.php index a3caf26..53ebb57 100644 --- a/src/Queue/SqsSnsQueue.php +++ b/src/Queue/SqsSnsQueue.php @@ -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, @@ -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']); + } }