What is ActiveMQ used for - can we apply messaging concept using a Database?

user34537 picture user34537 · Oct 9, 2012 · Viewed 88.5k times · Source

I looked it up and it used to send messages between 2 systems.
But why? Why wouldn't you just use a Database?
There must be some feature that ActiveMQ has that Databases do not?

Answer

Hiram Chirino picture Hiram Chirino · Oct 9, 2012

It is used to reliably communicate between two distributed processes.

Yes, you could store messages in a Database to communicate between two processes, but, as soon as the message is received you'd have to DELETE the message, That means a row INSERT and DELETE for each message.
When you try to scale that up communicating thousands of messages per second, Databases tend to fall over.

Message-oriented middle-ware [MOM] like ActiveMQ on the other hand are built to handle those use cases.
They assume that messages in a healthy system will be deleted very quickly and can do optimizations to avoid the overhead.

It can also push messages to consumers instead of a consumer having to poll for the new message by doing a SQL query.
This further reduces the latency involved in processing new messages being sent into the system.