RabbitMQ prefetch and message consumer order #5190
Closed
cdunnkiplot
started this conversation in
General
Replies: 1 comment 2 replies
-
You can use MassTransit with Kafka and it does in-order delivery per PartitionKey. If you're using |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am trying to use MT and RabbitMQ to implement Partial Ordering.
I have a RabbitMQ consistent hash exchange that distributes messages to several queues. Each queue has a single exclusive consumer that processes the messages. Each exclusive consumer then uses a MassTransit Partitioner to further increase throughput within the process. The hash exchange and MT Partitioner both use the same Partition Key to ensure messages for the same Key end up in the same queue and MT partition.
I almost had a good working solution until I noticed the prefetch count was using the default, which in my case resolved to 40, and according to your answer here, anything but a prefetch count of 1 means that message consume order is determined by the Task Scheduler, which is nondeterministic.
I can set the prefetch count to 1 but this massively reduces the throughput of my app. I guess I could create more RabbitMQ queues and deploy more instances of my app but this will complicate my deployment topology and consume more resources in my deployment environment, both of which aren't ideal for me.
I ran some tests using the default prefetch count and in all cases I found that the first prefetch batch would execute messages out of order, but thereafter it seemed to settle and consistently execute in order. I take this with a pinch of salt however as a production environment and resource contention could change this behaviour and so I can't rely on this.
Is there a way to make the message consumer order deterministic when a batch of messages are buffered into memory when pushed from RabbitMQ? if not currently, could it be possible? and if so, could you please point me to the related code?
I feel so close to something really great that could be a real contender to Kafka, but with all the features and benefits of MassTransit. If this can't be achieved then I might have to admit defeat and look into Kafka instead, but that comes with its own different set of problems and complexity.
Any help and guidance would be much appreciated!
Thanks
Beta Was this translation helpful? Give feedback.
All reactions