-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Club setting itacImport item count now updated has it's consume by th…
…e messenger
- Loading branch information
Showing
5 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\EventSubscriber\Kernel; | ||
|
||
use App\Message\ItacMembersMessage; | ||
use App\Service\ClubService; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent; | ||
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent; | ||
|
||
final class MessengerSubscriber implements EventSubscriberInterface { | ||
|
||
public static function getSubscribedEvents(): array { | ||
return [ | ||
WorkerMessageHandledEvent::class => [ | ||
['messageHandled', 10], | ||
], | ||
WorkerMessageFailedEvent::class => [ | ||
['messageFailed', 10], | ||
], | ||
]; | ||
} | ||
|
||
public function __construct( | ||
private readonly ClubService $clubService, | ||
) { | ||
} | ||
|
||
public function messageHandled(WorkerMessageHandledEvent $event): void { | ||
$message = $event->getEnvelope()->getMessage(); | ||
$this->consumeMessage($message); | ||
} | ||
|
||
public function messageFailed(WorkerMessageFailedEvent $event): void { | ||
// We only update the count for failed message | ||
if ($event->willRetry()) { | ||
return; | ||
} | ||
|
||
$message = $event->getEnvelope()->getMessage(); | ||
$this->consumeMessage($message); | ||
} | ||
|
||
private function consumeMessage(object $message): void { | ||
if ($message instanceof ItacMembersMessage) { | ||
$this->clubService->consumeItacImport($message->getClubUuid()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters