MassTransit: Message cannot be unscheduled from Azure Service Bus when in-memory outbox is used

Is this a bug report?

Yes

Can you also reproduce the problem with the latest version?

Yes

Environment

  1. Dotnet version: 3.1
  2. Operating system: Windows
  3. IDE (Rider, VS Code, Visual Studio): N/A

Steps to Reproduce

  1. Configure Azure functions to use the MassTransit Azure Functions transport
  2. Configure MassTransit to use the in-memory outbox (.UseInMemoryOutbox())
  3. Attempt to unschedule a message

Expected Behavior

The scheduled message should be unscheduled from Azure Service Bus

Actual Behavior

A CancelScheduledMessage is sent to the queue instead of unscheduling the message from Azure Service Bus.

I had to attach the debugger to figure this out. But when MassTransit schedules a messages on Azure Service Bus it encodes a sequence number into to the Token ID:

  • 00000220-0000-0000-a6e1-de45e154a675
  • 00000223-0000-0000-a6e1-de45e154a675
  • 00000233-0000-0000-a6e1-de45e154a675

This sequence number is stored in the Saga state in the database. However, when the in-memory outbox is used the token ID in the database is different:

  • c99f0000-e33c-482a-d0fe-08d8be46f843
  • c99f0000-e33c-482a-86b5-08d8be470302

I’m assuming this is because the saga is persisted before the message(s) in the outbox are actually scheduled.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Had it running for a bit now and it seems to be working as expected I haven’t seen any events in application insights yet that are triggered by the scheduled messages being delivered which is what I would expect because the messages are unscheduled ahead of time.