Chapter6: Adding RabbitMQ
This commit is contained in:
3
.env
3
.env
@@ -34,7 +34,8 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
|
||||
|
||||
###> symfony/messenger ###
|
||||
# Choose one of the transports below
|
||||
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
|
||||
MESSENGER_TRANSPORT_BASE_DSN=amqp://guest:guest@localhost:5672/%2f
|
||||
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
|
||||
# MESSENGER_TRANSPORT_DSN=doctrine://default
|
||||
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
|
||||
###< symfony/messenger ###
|
||||
|
||||
@@ -15,22 +15,23 @@ framework:
|
||||
middleware:
|
||||
- validation
|
||||
event.bus:
|
||||
default_middleware: allow_no_handlers
|
||||
middleware:
|
||||
- doctrine_ping_connection
|
||||
- doctrine_close_connection
|
||||
- doctrine_transaction
|
||||
- validation
|
||||
transports:
|
||||
# https://symfony.com/doc/current/messenger.html#transport-configuration
|
||||
async:
|
||||
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
|
||||
events: 'sync://'
|
||||
events:
|
||||
dsn: '%env(MESSENGER_TRANSPORT_BASE_DSN)%/events'
|
||||
# failed: 'doctrine://default?queue_name=failed'
|
||||
sync: 'sync://'
|
||||
routing:
|
||||
# One way to route the messages is using Interfaces or Parent Classes
|
||||
# that helps on not having to maintaining this routing 1 to 1 approach
|
||||
Cheeper\Chapter6\Application\Projector\Author\CountFollowers: async
|
||||
Cheeper\Chapter6\Application\Projector\Author\CountFollowers: sync
|
||||
# Cheeper\Chapter6\Application\Projector\Author\CountFollowers: events
|
||||
# 'Cheeper\Chapter5\Application\Query\CountFollowers': sync
|
||||
# 'Cheeper\DomainModel\DomainEvent': async
|
||||
Cheeper\DomainModel\DomainEvent: events
|
||||
# 'Cheeper\Application\Command\AsyncCommand': async
|
||||
# 'Cheeper\Application\Command\SyncCommand': sync
|
||||
|
||||
@@ -13,12 +13,13 @@ services:
|
||||
- 9200:9200
|
||||
- 9300:9300
|
||||
rabbitmq:
|
||||
image: rabbitmq
|
||||
image: rabbitmq:3-management
|
||||
ports:
|
||||
- 4369:4369
|
||||
- 5671:5671
|
||||
- 5672:5672
|
||||
- 25672:25672
|
||||
- 15672:15672
|
||||
mysql:
|
||||
image: mysql
|
||||
command: --default-authentication-plugin=mysql_native_password
|
||||
|
||||
@@ -21,7 +21,7 @@ final class SymfonyEventBus implements EventBus
|
||||
|
||||
public function notify(DomainEvent $event): void
|
||||
{
|
||||
$this->handle($event);
|
||||
$this->messageBus->dispatch($event);
|
||||
}
|
||||
|
||||
public function notifyAll(array $domainEvents): void
|
||||
|
||||
@@ -39,8 +39,8 @@ final class DoctrineOrmFollows implements Follows
|
||||
public function ofFromAuthorIdAndToAuthorId(AuthorId $fromAuthorId, AuthorId $toAuthorId): ?Follow
|
||||
{
|
||||
return $this->repository->findOneBy([
|
||||
'fromAuthorId' => $fromAuthorId,
|
||||
'toAuthorId' => $toAuthorId
|
||||
'fromAuthorId.id' => $fromAuthorId,
|
||||
'toAuthorId.id' => $toAuthorId
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user