Replies: 4 comments
-
// AsynchronousModule
if (in_array(get_class($annotationForMethod), [CommandHandler::class, EventHandler::class, InternalHandler::class])) {
if ($annotationForMethod->isEndpointIdGenerated()) {
if ($annotationForMethod->getInputChannelName()) {
// regenerate for async endpoint or set
} else {
throw ConfigurationException::create("{$endpoint} should have endpointId defined for handling asynchronously");
}
}
} |
Beta Was this translation helpful? Give feedback.
-
If we say that Message Consumer is actually Message Channel (as Ecotone for Message Channels does that simplification), then the routing to given channel is based on
So for Command Handler that could work, as there is always single Handler for it. However that still leave us with potential problem if we define it after Messages are already in the queue, however I do think this is acceptable (with a warning on the documentation page).
For Event Handlers however, remember that Ecotone is aiming for failure isolation. Therefore even if set of Event Handlers subscribe to same Event Message, each of them will receive it's own copy of it. Therefore in case of Event Handlers this does not seems feasible, as chance of B/C is much higher than in Command Handlers, which would eventually lead people in defining those endpointId by default anyway. Wdyt? |
Beta Was this translation helpful? Give feedback.
-
@dgafka You can define for command handlers and warn about the unsafety of this approach for event handlers in the documentation. |
Beta Was this translation helpful? Give feedback.
-
@lifinsky well for Command Handler it's fine, as it's unlikely that this will be a problem, however for Event Handlers we can't follow behaviour in this format, as we can't assume all developers knowing the internals of the framework. Therefore Ecotone should lead into direction that is safe by default. |
Beta Was this translation helpful? Give feedback.
-
Description
In Ecotone, when defining an asynchronous CommandHandler or EventHandler, developers currently need to specify both a
routingKey
and anendpointId
manually. This results in unnecessary duplication, asendpointId
is often a direct derivative ofroutingKey
.For example, the following declaration requires specifying
endpointId
explicitly:Since endpointId serves primarily as an identifier for the asynchronous consumer and doesn't necessarily need a separately assigned value, we propose that it be generated automatically based on the routingKey using a predefined convention — unless explicitly provided by the user.
Proposed Solution
If endpointId is not specified, Ecotone should automatically generate it using a standardized rule, such as:
So, the example above could be rewritten more concisely:
#[CommandHandler(routingKey: 'card.block.verify')]
This would significantly reduce verbosity while keeping full control for cases where developers want to specify a custom
endpointId
.Advantages
endpointId
declarations.endpointId
follows a predictable naming convention.endpointId
if needed.Beta Was this translation helpful? Give feedback.
All reactions