Skip to content

Commit

Permalink
implements route key TopicArn, Subject
Browse files Browse the repository at this point in the history
  • Loading branch information
jayhof committed Jan 24, 2018
1 parent 1470055 commit 93d9d3c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Queue/Jobs/SqsSnsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@ private function resolveSnsSubscription(array $job, array $routes)
{
$body = json_decode($job['Body'], true);

if (isset($body['Subject']) && array_key_exists($body['Subject'], $routes)) {
// Find name of command in queue routes
$commandName = $routes[$body['Subject']];
$commandName = null;

// available parameters to route your jobs by
$possibleRouteParams = ['TopicArn', 'Subject'];

foreach ($possibleRouteParams as $param) {
if (isset($body[$param]) && array_key_exists($body[$param], $routes)) {
// Find name of command in queue routes using the param field
$commandName = $routes[$body[$param]];
break;
}
}

if ($commandName !== null) {
// restructure job body
$job['Body'] = json_encode([
'job' => CallQueuedHandler::class . '@call',
Expand Down

0 comments on commit 93d9d3c

Please sign in to comment.