Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When, where & how should queues be used?

Tags:

java

queue

I'm new to enterprise Java development, although I'm sure this question equally applies to any language or platform, such as .NET.

For the first time ever now I'm dealing with message queues, and I'm very intrigued by them. (specifically, we're using ActiveMQ). My tech lead wants ActiveMQ queues to be the front-runners to all of our databases and internal web services; thus instead of a database query being fired off from the client and going directly to the database, it gets queued up first.

My question is this: are queues the way to go with every major processing component? Do best practices dictate putting them in front of system components that usually get hit with large amounts of requests? Are there situations where queues should not be used?

Thanks for any insight here!

like image 431
IAmYourFaja Avatar asked Sep 15 '11 12:09

IAmYourFaja


People also ask

What do you call what where when?

An interrogative word or question word is a function word used to ask a question, such as what, which, when, where, who, whom, whose, why, whether and how. They are sometimes called wh-words, because in English most of them start with wh- (compare Five Ws).


1 Answers

Here are some examples where a message queue might be useful.

Limited resources
Lets say you have a large number of users making requests to a service. If the service can only handle a small number of requests concurrently then you might use a queue as a buffer.

Service decoupling
A key enterprise integration concept is decoupling of systems in for eg a workflow. Instead of having systems talk directly to each other, they asyncronously post messages to queues. The integration component then routes and delivers the message to the appropriate system.

Message replay
In the above example queues can also provide reliable delivery and processing of requests. If one component of the workflow breaks, others are unaffected and can still operate and post messages to the broken component. When the broken component recovers it can process all the queued up messages.

They key concepts here are load throttling, loose coupling, reliability and async operation.

As to whether they are the way to go for every major component, I would say no, this is not an automatic choice, you must consider each component individually.

like image 103
Qwerky Avatar answered Oct 11 '22 01:10

Qwerky