messageId.Headers are helpful, to give extra insights about the message and how it should be handled. In
Ecotoneheaders and metadata means the same. Those terms will be used interchangeably.
User who registered the product, should be able to change it price.
Commandin a minute. Let's first add user information for registering the product. We will do it, using
Meta Data. Let's get back to our Testing Class
EcotoneQuickstartand add 4th argument to our
sendWithRouting, it accepts 4th argument, which is
associative array.Whatever we will place in here, will be available during message handling for us. So it's good place, to enrich the message with extra information, which we will want to use or store, but are is not part of the
command/query/event. Now we can change our
Ecotoneread parameters and evaluated what should be injected. We will see soon, how can we take control of this process. We can add
userIdand see, if we get the exception.
Only administrator should be allowed to register new product
UserServicewhich will tell us, if specific user is administrator. In our testing scenario we will suppose, that only user with
idof 1 is administrator.
UserService.The good place for it, would not allow for any invocation of
product.register commandwithout being administrator, otherwise our constraint may be bypassed.
Ecotonedoes allow for auto-wire like injection for endpoints. All services registered in Depedency Container are available.
isAdmin constraintmust be satisfied in order to register new product. Let's correct our testing class.
Ecotoneinject arguments based on
Parameter Converters. Parameter converters , tells
Ecotonehow to resolve specific parameter and what kind of argument it is expecting. The one used for injecting services like
Referenceparameter converter. Let's see how could we use it in our
user-servicein Dependency Container. Then we would need to set up the
Reference- Does inject service from Dependency Container. If
referenceName,which is name of the service in the container is not given, then it will take the class name as default.
Headers- Does inject all headers as array.
Ecotone, if parameter converters are not passed provides default converters. First parameter is always
@Payload.The second parameter, if is
@Headersconverter is taken, otherwise if class type hint is provided for parameter, then
@Referenceconverter is picked. If we would want to manually configure parameters for
product.registerCommand Handler, then it would look like this: