rebus-org / Rebus.SqlServer

:bus: Microsoft SQL Server transport and persistence for Rebus
https://mookid.dk/category/rebus
Other
43 stars 44 forks source link

How should the "priority" of messages be used ? #12

Closed IsaacSee closed 7 years ago

IsaacSee commented 7 years ago

I noticed a "Priority" column on messages table but it seems that it is not really used. What should be the way to use it in order to process higher priorities first ?

mookid8000 commented 7 years ago

It's an undocumented feature that the SQL transport can choose to use 😄

Prioritizing messages is not really supported by any other transports, so the feature has no API in Rebus – but you can see here that the SQL transport does in fact select its next message based on the priority in ascending order.

Only thing you need to do is to set the rbs2-message-priority header to a number when you send the message, e.g. like this:

var headers = new Dictionary<string, string> {
    {"rbs2-message-priority", "100"}
};

await bus.Send(work, headers);

to assign the priority 100 to the message.


sorry for not replying sooner, btw – I saw your message while I was on the move, and then I completely forgot about it!