EcotoneAPI — including the gateway class,
Ecotoneprovides the Gateway as interface. Framework generates a proxy for any interface and internally invokes the gateway methods. By using dependency injection, you can then expose the interface to your business methods.
Ecotoneprovides to us.
Command Handler. Command Handler is place where we will put our business logic. Let's create namespace
RegisterProductCommand,command for registering new product:
Ecotonewill read method declaration and base on the first parameter type hint will know that this
CommandHandleris responsible for handling
ProductServicefor registered products. This is the role of
Query Handlers. They do query the state and return it to us. Let's starts with
GetProductPriceQueryclass. This query will tell us what is the price of specific product.
Query Handlerto the
Messageand send it to correct
Message Channel. In order to do it we will use Messaging Gateway. Message Gateways are responsible for creating
Messagefrom given parameters and send it to the correct
channel. For sending Commands we will use
Command Bus Gateway. For sending Queries we will use
Query Bus Gateway. Let's inject and call Query and Command bus into EcotoneQuickstart class.
Gatewaysare auto registered in Dependency Container and available for auto-wire.
Ecotonecomes with few set up Gateways. Command and Query buses are available instantly to you. You will be able to extend them or create your own ones, if needed.
CommandHandlerwe registered before.
Event Bus Gatewaywhich can publish events. Let's start by creating
CommandHandlerin order to publish
ProductWasRegisteredEventafter product was registered.
EventBusis injected into the Command Handler's method.
Ecotonedoes control method invocation for endpoints, if you have type hinted for specific class, framework will look in Dependency Container for specific service in order to inject it automatically. It does work similar to auto-wire system. If you want to know more, check chapter about Method Invocation.
Ecotoneto handle specific event based on declaration type hint, just like with
point to point,which means they are targeting one Handler,
Eventson other side are
publish subscribe, which means, there may be multiple Handlers for specific event.