In Ecotone
, an object may declare a number of query handler methods, by annotating them with the @QueryHandler
annotation.
For a query handler method, the first declared parameter defines which query message object it will receive.
use Ecotone\Messaging\Annotation\MessageEndpoint;use Ecotone\Modelling\Annotation\QueryHandler;/*** @MessageEndpoint()*/class OrderSummary{/*** @QueryHandler()*/public function getOrders(GetOrdersQuery $query) : array{//return orders}}
To route Message
to @QueryHandler
by name we can use inputChannelName.
In below example Message will be routed by order.getOrders
.
use Ecotone\Messaging\Annotation\MessageEndpoint;use Ecotone\Modelling\Annotation\QueryHandler;/*** @MessageEndpoint()*/class OrderSummary{/*** @QueryHandler(inputChannelName="order.getOrders")*/public function getOrders(GetOrdersQuery $query) : array{//return orders}}
Query can be anything class/scalar/array
as long as Ecotone does know how to convert it.
Read more in Method Invocation and Conversion