Fix UseDurableOutboxOnAllSendingEndpoints and UseDurableInboxOnAllListeners with SignalR #2045
+59
−3
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.
UseDurableOutboxOnAllSendingEndpoints()andUseDurableInboxOnAllListeners()throwingInvalidOperationExceptionwhen SignalR transport is configuredSupportsMode(EndpointMode mode)method toEndpointclassEndpointproperty toISubscriberConfigurationinterfaceNotes
I realize this might need a major version bump, so I want to confirm we are not blocked, we adjusted so we don't need to call them. Not precious if the current behavior is fine, I can close and raise a docs adjustment PR instead.
Public API Additions
1.
Endpoint.SupportsMode(EndpointMode mode)methodThis exposes the existing protected
supportsMode()method, allowing users and policies to check endpoint mode compatibility before attempting to set a mode. This is useful for building custom policies that need to gracefully handle transports with limited mode support.2.
ISubscriberConfiguration.EndpointpropertyExposes the underlying
Endpointon the subscriber configuration interface, enabling policies to access endpoint properties (likeSupportsMode()) when configuring senders viaAllSenders().Problem
When
UseDurableOutboxOnAllSendingEndpoints()orUseDurableInboxOnAllListeners()is called and SignalR transport is configured, the application throws anInvalidOperationExceptionbecause SignalR doesn't support durable mode.Solution
Modified the two durability policy methods to check if the endpoint supports durable mode before attempting to set it. Endpoints that don't support durable mode are silently skipped.
Changes
Endpoint.csSupportsMode(EndpointMode mode)method that exposes the protectedsupportsMode()for policy checksISubscriberConfiguration.csEndpointproperty to the interface to expose the underlying endpoint for policy checksWolverineOptions.Policies.csUseDurableInboxOnAllListeners()to checkSupportsMode(EndpointMode.Durable)before callingUseDurableInbox()UseDurableOutboxOnAllSendingEndpoints()to checkSupportsMode(EndpointMode.Durable)before callingUseDurableOutbox()SignalRTransportModeTests.cs(new)Test plan
Design Rationale
UseDurableInbox()orUseDurableOutbox()on a SignalR endpoint will still throw an exception (correct behavior - users should know unsupported functionality was requested)AllListeners/AllSendersinfrastructure with an added mode checkFeedback Requested
Silent skipping behavior
This PR silently skips endpoints that don't support durable mode. This affects:
UseJetStreamis falseQuestion: Should we log a warning when endpoints are skipped? For example:
Considerations:
bool warnOnSkip = falseparameter to the policy methods