4

I am running a .net MVC4 web application. I want to be able to hit an action on a controller, create an email and send it to my service bus queue to be processed (sent).

What are my options as far as creating a consumer for my queue?

I've considered creating another project that runs when the web app is started that continually checks the queue state and processes messages as they come in.

I was wondering if there were any other solutions to processing messages.

1 Answer 1

1

A second project that checks the queue and process messages is what I would do. Background processing belongs to background workers.

Just remember that you don't have to continuously monitor the queue, if you are using a Service Bus queue: plain Azure queues are non-blocking, but Service Bus queues offer blocking receive operations which block the calling thread until a message arrives on a queue or a specified timeout period has elapsed.

So you just have to call your receive function in a loop, and it will stay there and wait for the next call. You can read the initial paragraphs of this article: it is about performances, which is not your case, but the initial overview is good for grasping the fundamentals.

2
  • Thank you for your suggestion, Lorenzo. I'll take a look at the articles you referenced. I spoke with some of my colleagues and they said that an azure worker role may also be a viable option. I'll take your suggestion into consideration. Cheers!
    – Daryl
    Sep 4, 2015 at 10:29
  • Yes, definitely! I naturally assumed that when you talked about "a second project" you meant an Azure worker role, not another Web project/Azure web role. My bad for making this assumption, I should have been clearer Sep 4, 2015 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.