We are using Azure Service Bus to notify subscribers when a certain entity in our application has changed to a certain state. Right now we're doing this right after we call dbContext.SaveChangesAsync():
dbContext.SaveChangesAsync()
topicClient.SendAsync(someMessage)
The problem I'm having is this: Say the dbContext.SaveChangesAsync() goes through fine, but for whatever reason the call to topicClient.SendAsync() throws an exception. Now the subscribers to this topic won't be aware of the entity's change in state.
I tried using TransactionScope, but that doesn't work because, as I gathered, Azure doesn't use the DTC.
(I could switch the order of the above 2 steps, but then if the message sends fine and the save fails, the message contains bogus data.)
Does anyone have any suggestions on how to handle this issue? It seems like one that should be common, but I can't find anything online. If someone could point me in the right direction, I'd appreciate it.
Thank you in advance.