Skip to content

Instantly share code, notes, and snippets.

@dgafka
Last active May 14, 2022 12:41
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/65b35e6d053f6ac07cc2f5d4545f379d to your computer and use it in GitHub Desktop.
Save dgafka/65b35e6d053f6ac07cc2f5d4545f379d to your computer and use it in GitHub Desktop.
asynchronous-messaging-13.php
<?php
// Configuration on Publisher Side
public function changeBillingDetails(DistributedBus $distributedCommandBus)
{
$distributedCommandBus->sendCommand(
"billing", // destination
"billing.changeDetails", // routingKey
'["personId":"123","billingDetails":"01111"]',
"application/json"
);
// or, if you want delegate serialization to Ecotone or you woud like to share classes between applications
$distributedCommandBus->convertAndSendCommand(
"billing", // destination
"billing.changeDetails", // routingKey
new ChangeBillingDetails(// data),
"application/json"
);
}
// Configuration on "billing" Service - Consumer Side
#[Distributed]
#[CommandHandler("billing.changeDetails")]
public function changeBillingDetails(ChangeBillingDetails $command) : void
{
// Ecotone will deserialize the payload to ChangeBillingDetails automatically.
// There is no need to share classes between Applications.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment