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): void
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:
$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
endpointId declarations.
- Consistency – Ensures
endpointId follows a predictable naming convention.
- Backward Compatibility – Developers can still specify a custom
endpointId if needed.
Description
In Ecotone, when defining an asynchronous CommandHandler or EventHandler, developers currently need to specify both a
routingKeyand anendpointIdmanually. This results in unnecessary duplication, asendpointIdis often a direct derivative ofroutingKey.For example, the following declaration requires specifying
endpointIdexplicitly: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
endpointIddeclarations.endpointIdfollows a predictable naming convention.endpointIdif needed.