MassTransit Transaction - Publish from ASP.NET MVC and Consume from Topshelf service

54 views
Skip to first unread message

ManishB Aegis

unread,
Oct 13, 2017, 10:41:29 AM10/13/17
to masstransit-discuss
- My current scenario is that I am updating an Employee entity in DB from ASP.NET MVC application and after that update I am publishing a contract entity IEmployeeAudit and insert it into EmployeeUpdateAudit table using Topshelf service.
- So, Can I put both statement in a single transaction ?
- e.g.,
Begin Transaction
Update(objEmployee)---------------------From web app
Publish(empAudit)
Inside Consume() Create(empAudit)---In TopShelf Service
Commit Transaction

Alexey Zimarev

unread,
Oct 13, 2017, 1:49:38 PM10/13/17
to masstransit-discuss
Do not do that. Distributed transactions is the source of evil. Do a transaction on the MVC side or if you want to have decoupled invocation - do all in consumer. If you need to confirm that database transaction has been completed - use request/response. If you have doubts for the second db operation to complete in the consumer - use retry policies.

Redesign your solution to use messaging patterns. Do not try spanning consistency boundaries across consumers. This is not what messaging is for.
Reply all
Reply to author
Forward
0 new messages