rabbitmqmasstransitrouting-slip

MassTransit - Prioritize RabbitMQ Message on Routing Slip


RabbitMQ supports message priority: https://www.rabbitmq.com/priority.html

MassTransit allows user to set this up when configuring endpoints and when sending/publishing a message.

Question: Would it be possible to set a message priority when using a Routing Slip in MassTransit?

My Problem: We have a screen that can schedule items or process them right away. If scheduled, items can be processed in batches. If hundreds of items are processed at the same time, saving a record on the screen can take minutes because the message would go to the end of the queue, which can lead to a bad user experience.

So, if it's not possible to set the priority, what is the alternative here?

Thanks!


Solution

  • Your easiest option? Setup your activity services so that they host two endpoints, one for execute (anything, including batch) and one for execute-interactive, that you use when it is an interactive request. When you build the routing slip, use the appropriate queues for the activity execution, and you're off and running. Batch won't interfere because it's on a separate set of endpoints.

    Your other option is a lot harder, and would involve creating send middleware that looks for RoutingSlip and checks some value and sets the priority.