-
-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Description
In Ecotone, when defining an asynchronous CommandHandler or EventHandler, developers currently need to specify both a routingKey and an endpointId manually. This results in unnecessary duplication, as endpointId is often a direct derivative of routingKey.
For example, the following declaration requires specifying endpointId explicitly:
#[CommandHandler(routingKey: 'card.block.verify', endpointId: 'card.block.verify.endpoint')]
#[Asynchronous(MessagingChannel::Internal->value)]
#[Delayed(new TimeSpan(seconds: 30))]
public function verifyCardBlocked(Card $card): voidSince 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:
$endpointId = $routingKey . '.endpoint'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
- Less Boilerplate – Reduces redundant
endpointIddeclarations. - Consistency – Ensures
endpointIdfollows a predictable naming convention. - Backward Compatibility – Developers can still specify a custom
endpointIdif needed.