Priority Queue with RabbitMQ

1,282 views
Skip to first unread message

Pranav Prakash

unread,
Dec 20, 2011, 1:05:10 AM12/20/11
to rabbitmq...@googlegroups.com
Hi Folks,

I am planning to use RabbitMQ for our an upcoming project, in email queue purposes. So, we have three main types (priorities) of emails that we want to send out - 
  • High Priority - Must be send ASAP
  • Medium Priority - Must be send within 12/24 hr window
  • Low Priority - Time of delivery does not matters
There are couple of producer processes, which generate message body (to, subject, email message, priority) and then a couple of consumer processes using an API call to send emails.

What would be a good approach to fit the priority into this otherwise ideal world scenario?

Alexis Richardson

unread,
Dec 20, 2011, 7:20:16 AM12/20/11
to rabbitmq...@googlegroups.com
Pranav

On Tue, Dec 20, 2011 at 6:05 AM, Pranav Prakash <pra...@gmail.com> wrote:
> Hi Folks,
>
> I am planning to use RabbitMQ for our an upcoming project, in email queue
> purposes.

Excellent.


> So, we have three main types (priorities) of emails that we want
> to send out -
>
> High Priority - Must be send ASAP
> Medium Priority - Must be send within 12/24 hr window
> Low Priority - Time of delivery does not matters
>
> There are couple of producer processes, which generate message body (to,
> subject, email message, priority) and then a couple of consumer processes
> using an API call to send emails.
>
> What would be a good approach to fit the priority into this otherwise ideal
> world scenario?

Have a look at this tutorial:

http://www.rabbitmq.com/tutorials/tutorial-four-python.html
http://www.rabbitmq.com/tutorials/tutorial-four-java.html

You could achieve your goal by using a direct exchange and three
queues bound to that exchange with, respectively, the binding keys:
"high", "medium", and "low". The producer should attach one of these
three keys to each message, when it publishes that message. The
consumers should connect to the queues in what I hope is the obvious
way, such that they can relay messages to the email service(s).

Cheers

alexis


> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq...@lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>

Pranav Prakash

unread,
Dec 20, 2011, 11:11:19 AM12/20/11
to rabbitmq...@googlegroups.com
Awesome. This is approx the same as what I was thinking. I am really excited about rabbit mq and would come up with more questions :)

Kudos to the team !!

Eknath Iyer

unread,
May 2, 2014, 6:22:23 PM5/2/14
to rabbitmq...@googlegroups.com
To jump on this conversation, 
let's say there is 2 messages in "high" and "med" each. consumer c1 is subscribed to both of them.
let's say "med" got both the messages first, so it sends 1 it to c1. But before "med" sends the next message to c1, how would you configure "high" to send both its messages to c1.

I'm not looking to pre-empt c1's processing of the first "med" message, but definitely process "high" messages before "med".

Thanks
Reply all
Reply to author
Forward
0 new messages