Imagine a situation:
var txn = new DatabaseTransaction(); var entry = txn.Database.Load<Entry>(id); entry.Token = "123"; txn.Database.Update(entry); PublishRabbitMqMessage(new EntryUpdatedMessage { ID = entry.ID });
Now, the EntryUpdatedMessage consumer can receive this message before transaction txn is committed and, therefore, cannot see the update.
Now I know that RabbitMQ does support transactions on its own, but we cannot use them because we create a new IModel for each publication and having a model for each thread is really cumbersome in our script (ASP.NET application website).
I was thinking about having a list of messages that should be published during the database transaction, but this is really a smelly solution.
What is the correct way to solve this problem?
source share