To send an Query we will be using send method on QueryBus.
Query will be delivered to corresponding Query Handler.
classTicketController{// Query Bus will be auto registered in Depedency Container.publicfunction__construct(privateQueryBus $queryBus) {}publicfunctioncreateTicketAction(Request $request) :Response { $result =$this->queryBus->send(newGetTicketById( $request->get("ticketId") ));returnnewResponse(\json_encode($result)); }}
If you have registered Converter for specific Media Type, then you can tell Ecotone to convert result of your Query Bus to specific format.
In order to do this, we need to make use of Metadataand replyContentType header.
classTicketController{publicfunction__construct(privateQueryBus $queryBus) {}publicfunctioncreateTicketAction(Request $request) :Response { $result =$this->queryBus->sendWithRouting("ticket.getById", $request->get("ticketId"),// Tell Ecotone which format you want in return expectedReturnedMediaType:"application/json");returnnewResponse($result); }}