Skip to content

[Host] CancellationToken is not included as an OnHandle method paramter #223

Closed

Description

@EtherZa

Neither IConsumer nor IRequestHandler include the CancellationToken associated with the message context as a method parameter.

It is accessible via IConsumerContext injection, but the implementation is not ideal as it breaks the facade of isolation from the message broker. Using setter injection also negates the ability to use a single consumer instance for concurrent processing.

Activity

  1. zarusz commented on Mar 30, 2024

    @zarusz
    Owner

    I agree in general, it would be better to have CancellationToken added as part of the consumer method.

    There could also be an improvement added for concurrent consumers (.Instances(N) where N > 1) where the message processing pipeline would create N per-message scopes, rather than 1 nowadays.

    In the long run, I was considering adding CancellationToken to the consumer methods in the future SMB v3. This perhaps would result in a breaking change to IConsumer<T>, or an additional interface that could be used.

    I saw you have the PR for this feature using the consumer without the interface, which is a good middle-ground before v3.

  2. added this to the 2.3.0 milestone on Mar 30, 2024
  3. zarusz commented on Apr 2, 2024

    @zarusz
    Owner

    Closed via #224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions