Skip to content

Conversation

Copy link

Copilot AI commented Sep 5, 2025

This PR provides a comprehensive analysis of the existing RescheduleCurrentAsync implementation in response to questions about whether convenience methods are sufficient or if custom headers are needed to prevent duplicate envelope insertion when using Azure Service Bus with durable inbox.

Key Findings

The existing implementation is correct and optimal. Here's why:

For Azure Service Bus with UseDurableInbox()

When using:

opts.ListenToAzureServiceBusQueue("test")
    .UseDurableInbox()

The flow works as follows:

  1. Native Scheduling Path: DurableReceiver implements ISupportNativeScheduling
  2. Automatic UPDATE behavior: Calls MoveToScheduledUntilAsync_scheduleExecutionIMessageInbox.ScheduleExecutionAsync
  3. No duplicates: ScheduleExecutionAsync always performs an UPDATE on the existing incoming envelope row
  4. Header ignored: The RescheduleExistingKey header is safely ignored but provides universal compatibility

Current Implementation Analysis

public override async Task RescheduleCurrentAsync(DateTimeOffset rescheduledAt)
{
    // Mark the envelope for rescheduling existing record as documented
    Envelope?.MarkForRescheduleExisting();
    await ReScheduleAsync(rescheduledAt);
}

This approach provides:

  • Universal safety across all transport types
  • Native scheduling optimization for transports that support it (Azure Service Bus, etc.)
  • Fallback protection for non-native scheduling transports

Answer to the Original Question

For Azure Service Bus with durable inbox specifically: The convenience method alone would be sufficient since native scheduling ensures UPDATE behavior.

For universal robustness: The current implementation with custom headers is optimal as it:

  • Works correctly with Azure Service Bus (header ignored, native path used)
  • Prevents duplicates on other transports (header enforces UPDATE vs INSERT)
  • Provides consistent behavior across all Wolverine transports

Conclusion

The existing RescheduleCurrentAsync implementation is correct and should be maintained as-is. The custom header logic provides valuable safety guarantees across different transport types while being optimally handled by native scheduling implementations like Azure Service Bus with durable inbox.

No code changes were required - the analysis confirms the implementation already handles the described scenario correctly.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] if I use Azure Service bus queue listener and I use UseDurableInbox() we will guarantee at most once delivery (the message to processed will be stored in the incoming envelopes table - im using sql server backed persistence): opts.ListenToAzureServiceB... Analysis and Documentation: RescheduleCurrentAsync Implementation for Azure Service Bus with Durable Inbox Sep 5, 2025
Copilot AI requested a review from punxrok September 5, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants