Skip to content

Instantly share code, notes, and snippets.

@dgafka
Last active July 12, 2023 15:34
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/2cd6ea262079852f63b366a14f6bb095 to your computer and use it in GitHub Desktop.
Save dgafka/2cd6ea262079852f63b366a14f6bb095 to your computer and use it in GitHub Desktop.
microservices-integration-in-php-04.php
<?php
class OrderService
{
public function __construct(private DistributedBus $distributedBus) {}
public function placeOrder(int $personId, array $products): void
{
$this->distributedBus->sendCommand(
"order_service", // 1. External Service Name
"placeOrder", // 2. Routing in external Service
\json_encode(["personId" => $personId, "products" => $products]), // 3. Our payload
"application/json" // 4. Content-Type of payload
);
}
}
// with Converters we could let Ecotone to do the conversion.
public function placeOrder(int $personId, array $products): void
{
$this->distributedBus->convertAndSendCommand(
"order_service", // 1. External Service Name
"placeOrder", // 2. Routing in external Service
new PlaceOrder($personId, $products) // 3. Our payload
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment