Skip to content

Commit

Permalink
applied requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
otanim committed Oct 30, 2024
1 parent e3174ae commit d6a21d3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/ServiceBusSQSChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(array $config = [])
protected function initializeSqsClient(): void
{
$this->sqs = new SqsClient([
'region' => Arr::get($this->config, 'sqs.region'),
'region' => Arr::get($this->config, 'sqs.region', 'eu-west-1'),
'version' => 'latest',
'credentials' => [
'key' => Arr::get($this->config, 'sqs.key'),
Expand Down Expand Up @@ -77,15 +77,22 @@ public function send($notifiable, Notification $notification): void
$payloadSqs['MessageDeduplicationId'] = md5(json_encode($params));
}

$this->sendMessageToSqs($payloadSqs, $eventType, $params, $dontReport);
}

protected function sendMessageToSqs(array $payloadSqs, string $eventType, array $params, array $dontReport): void
{
try {
$response = $this->sqs->sendMessage($payloadSqs);

$eventName = $params['events'][0];

Log::info("{$eventName} sent to bus queue", [
'message_id' => $response->get('MessageId'),
'params' => $params,
]);
if (!in_array($eventType, $dontReport)) {
Log::info("{$eventName} sent to bus queue", [
'message_id' => $response->get('MessageId'),
'params' => $params,
]);
}

$this->hasAttemptedRefresh = false;
} catch (AwsException $exception) {
Expand All @@ -105,7 +112,7 @@ public function send($notifiable, Notification $notification): void

$this->initializeSqsClient();

$this->send($notifiable, $notification);
$this->sendMessageToSqs($payloadSqs, $eventType, $params, $dontReport);
} else {
$this->hasAttemptedRefresh = false;

Expand Down

0 comments on commit d6a21d3

Please sign in to comment.