Skip to content

Instantly share code, notes, and snippets.

@dgafka
Created September 30, 2022 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgafka/569975e0004524a375c57833c759e15c to your computer and use it in GitHub Desktop.
Save dgafka/569975e0004524a375c57833c759e15c to your computer and use it in GitHub Desktop.
loosely-coupled-microservices-07.php
<?php
class OrderService
{
#[EventHandler]
public function placeOrder(OrderWasPlaced $event, DistributedBus $distributedBus): void
{
$distributedBus->convertAndSendCommand(
"payment_gateway_service",
"payment.charge_card",
[
"userId" => $event->userId(),
"amount" => $event->price()
]
);
}
}
class PaymentService
{
#[Distributed]
#[CommandHandler("payment.charge_card")]
public function placeOrder(ChargeCard $command): void
{
// charge card
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment