feat: async endpoint annotations for per-handler interceptor configuration#654
Merged
feat: async endpoint annotations for per-handler interceptor configuration#654
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why is this change proposed?
When async handlers (especially ProjectionV2) run on asynchronous endpoints, interceptors like
DbalTransactionInterceptorandCollectorSenderInterceptorwrap the entire execution — overriding the handler's own per-batch transaction management. There was no way to configure interceptor behavior per-handler on async endpoints because the Bridge is shared across all handlers on a channel, and handler-specific attributes were invisible at the async consumer level.This introduces new Enterprise feature:
endpointAnnotationson the#[Asynchronous]attribute, allowing per-handler interceptor configuration that is resolved at runtime when the message is fetched from the channel.Usage Examples
Per-handler interceptor configuration:
Custom async endpoint attribute:
ProjectionV2 — automatic, no user action needed:
For new Projecting system, we honour batch and flush based projecting. Meaning we don't want to start long transaction, which will end up when all events will be projected. As for global tracked projections that could span long running transaction.
Flow
sequenceDiagram participant Queue as Async Channel participant Poll as PollToGatewayTaskExecutor participant Registry as AsyncHandlerAnnotationRegistry participant Context as AsyncEndpointAnnotationContext participant Interceptor as DbalTransactionInterceptor participant Handler as Message Handler Poll->>Queue: poll message Poll->>Poll: read routing slip[0] Poll->>Registry: getAnnotationsForChannel(executionChannel) Poll->>Context: setAnnotations([WithoutDatabaseTransaction]) Poll->>Interceptor: gateway.execute() Interceptor->>Context: resolve ?WithoutDatabaseTransaction Note over Interceptor: skip transaction (attribute present) Interceptor->>Handler: proceed() Handler-->>Poll: done Poll->>Context: clear()Pull Request Contribution Terms