fix: restore tenant context for error channel in multi-tenant setup#677
Merged
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?
Fixes #676. In a multi-tenant setup, when a polling consumer fails and the message is routed to a DBAL Dead Letter error channel,
DbalDeadLetterHandlercrashes withLack of context about tenant in Message Headers. By the time the error-channel interceptor catches the exception, the interceptor chain has already unwound — the tenant was deactivated and the propagated-headers context popped — soHeaderBasedMultiTenantConnectionFactory::createContext()cannot resolve any connection. Failed messages can never reach the dead letter, and the consumer crashes instead of self-healing.Description of Changes
ErrorChannelServicenow re-establishes the failed message's header context (viaMessageHeadersPropagatorInterceptor::storeHeaders) around the send to the error channel, so the tenant header of the failed message is visible again to any tenant-aware component downstreamErrorChannelService(not in the DBAL dead letter handler) so custom error handlers and other integrations regain tenant context as wellNo configuration changes are needed — existing multi-tenant setups start working:
When a handler for
tenant_afails, the message is now stored inecotone_error_messagesin tenant A's database.sequenceDiagram participant Consumer as Polling Consumer participant Ack as AcknowledgeInterceptor participant Error as ErrorChannelInterceptor participant Headers as HeadersPropagator participant Handler participant DLQ as DbalDeadLetterHandler Consumer->>Ack: message (tenant: tenant_a) Ack->>Error: proceed Error->>Headers: proceed (push tenant header context) Headers->>Handler: handle Handler--xHeaders: exception (context popped on unwind) Headers--xError: exception Note over Error: NEW: restore failed message's<br/>header context around send Error->>DLQ: store failed message DLQ->>DLQ: resolve tenant_a connection ✔ Error-->>Ack: handled Ack->>Ack: accept()Pull Request Contribution Terms