Skip to content

Fix MessageContext to support native scheduling for non-durable inline senders#1810

Merged
jeremydmiller merged 3 commits intoJasperFx:mainfrom
kakins:asb-inline-sender-scheduling-fix
Nov 5, 2025
Merged

Fix MessageContext to support native scheduling for non-durable inline senders#1810
jeremydmiller merged 3 commits intoJasperFx:mainfrom
kakins:asb-inline-sender-scheduling-fix

Conversation

@kakins
Copy link
Contributor

@kakins kakins commented Nov 4, 2025

Problem

Scheduled messages sent with "inline senders" (e.g., Azure Service Bus) supporting native scheduling are always scheduled in memory, causing messages to be lost after service restarts.

Cause

When scheduling messages (via MessageContext.Schedule, MessageContext.Send with DeliveryOptions, or TimeoutMessages), MessageContext currently checks only if the sender is durable. Inline senders like ASB are always marked as non-durable, so their scheduled messages are routed to local in-memory scheduling—even if the transport supports true native scheduled delivery.

Solution

  • Fix the logic in MessageContext to also check whether the transport supports native scheduled delivery.
  • Instead of only checking IsDurable, the code now checks both IsDurable and SupportsNativeScheduledSend.
  • If SupportsNativeScheduledSend is true, scheduled messages are routed to the transport's native scheduling mechanism rather than to local in-memory scheduling.

Testing

Azure Service Bus

  • All tests pass but 4
  • Failing are related leadership election and named brokers -- seemingly unrelated, so probably local infrastructure(?)
image

Postgres

  • All tests pass but 1
  • Code under test never involves the change in this PR, so the failure is unlikely to be related
image

SQL Server

  • All tests pass
image

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