MassTransit - competing consumers across multiple computers.

216 views
Skip to first unread message

James Pennington

unread,
Jun 20, 2017, 4:39:01 PM6/20/17
to masstransit-discuss
I've got an existing app that I am looking to use MassTransit. Currently, the application has event messages put into a RabbitMQ queue and a windows service pulls them off one at a time. I would like to move this so that MassTransit can push out the messages to multiple consumers setup across multiple servers. The application should also only process messages with the same correlation ID one at a time across all of the consumer instances. 

I was able to get the partitioner middleware setup easy enough to do this on one instance of the windows service, but from what I've seen and read this only works across a single process and not across multiple computers. Is there anything integrated in MassTransit like this that would handle events getting generated with the same correlation ID but only be processed one at a time across multiple computers? I've got some ideas on how to handle in the consumer but I don't want to do something custom that is already supported.

Thanks!
James 

Chris Patterson

unread,
Jun 20, 2017, 10:47:29 PM6/20/17
to masstrans...@googlegroups.com
If you need to lock that way, you need to use a saga that supports pessimistic locking. Like NHibernate or Entity Framework. That way, the consumers use the database to lock by the correlated ID, ensuring only one message per ID is processed at a time.

James Pennington

unread,
Jun 21, 2017, 7:42:41 AM6/21/17
to masstransit-discuss
Thanks!!
I was thinking I might have to use the database or redis to handle this. I hadn't thought of adding a saga in there though. 
Reply all
Reply to author
Forward
0 new messages