Skip to content

Automatic endpointId generation based on routingKey for asynchronous endpoints #439

@lifinsky

Description

@lifinsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions