generated from oskarbarcz/symfony-project-bootstrap
-
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.
Establish connection to producer app
- Loading branch information
Showing
7 changed files
with
66 additions
and
20 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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
framework: | ||
messenger: | ||
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling. | ||
# failure_transport: failed | ||
|
||
transports: | ||
async: '%env(MESSENGER_TRANSPORT_DSN)%' | ||
async_users: | ||
dsn: '%env(MESSENGER_TRANSPORT_DSN)%' | ||
external_messages: | ||
dsn: '%env(MESSENGER_TRANSPORT_DSN)%' | ||
options: | ||
auto_setup: true | ||
exchange: | ||
name: messages | ||
type: direct | ||
default_publish_routing_key: from_external | ||
queues: | ||
messages: | ||
binding_keys: [ from_external ] | ||
|
||
routing: | ||
'App\Command\CreateUserCommand': async | ||
|
||
# when@test: | ||
# framework: | ||
# messenger: | ||
# transports: | ||
# # replace with your transport name here (e.g., my_transport: 'in-memory://') | ||
# # For more Messenger testing tools, see https://github.com/zenstruck/messenger-test | ||
# async: 'in-memory://' | ||
'App\Message\UserInfo': async_users |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Message; | ||
|
||
use App\Entity\User; | ||
|
||
final readonly class UserInfo | ||
{ | ||
public function __construct( | ||
private User $user | ||
) {} | ||
|
||
public function getUser(): User | ||
{ | ||
return $this->user; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Message; | ||
|
||
use App\Entity\User; | ||
use App\Repository\UserRepositoryInterface; | ||
use Symfony\Component\Messenger\Attribute\AsMessageHandler; | ||
|
||
#[AsMessageHandler] | ||
final readonly class UserInfoHandler | ||
{ | ||
public function __construct(private UserRepositoryInterface $repository) {} | ||
|
||
public function __invoke(UserInfo $command): void | ||
{ | ||
$user = new User( | ||
$command->getUser()->getId(), | ||
$command->getUser()->getFirstName(), | ||
$command->getUser()-> getSurname(), | ||
$command->getUser()->getEmail() | ||
); | ||
|
||
$this->repository->save($user); | ||
} | ||
} |
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