The good, the bad…
What is MQ?
• MQ (message queue) - is a system that allows two
or more processes to interact (communicate) via
• The code that sends a piece of data (message)
and the code that receives that piece of data
(message) do not interact directly and (should)
know nothing about each other.
• A message (usually) is NOT processed at the
moment when it is sent. Processing can happen
at any moment or can not happen at all.
• Edge case: RPC mode, when sender is waiting
(blocking the execution) until message is
Key elements: publisher
• Publisher (producer) - the app that generates messages
and pushes (publishes) them into an MQ.
Key elements: broker (exchange)
• Broker (exchange) - the main piece of the MQ
architecture, the app that decides how messages are
delivered to the consumer. It also provides persistency (if
needed), messages acknowledgement and re-delivery (if
Key elements: consumer
• Consumer (subscriber) - the part of an app that receives a
message from the broker and processes it. Usually this
part of application is called “worker” - a script(s) that is
waiting for a new message to process.
Key terms: Blocking
Blocking means that the code execution is stopped (paused)
after making a call or request to a long running service until
the service returns a result.
Key terms: Non-blocking
Non-blocking execution means that code continues after
making a call or request to a long running service and does
not wait for the result or output.
Dark side of the MQ
• Yet another beast in the zoo;
• Integrating with existing code is tricky;
• Concurrency issues;
• Self blocking queues;
• Testing and debugging pain;
• Monitoring and maintenance;
Key terms: Synchronous
Synchronous execution means execution in the same time
line, connected threads. In this case all code in all processes
is executed at the same speed and all processes are aware
of state of other processes.
Key terms: Asynchronous
Asynchronous execution means that all threads or processes
are executed independently with no specific order.
• Be aware of duplicated messages;
• Messages are processed in no particular order;
• Automated integration tests are impossible and make little
• Response of local vs production environment under load is
• Debugging is difficult - no united stack tracing available
(out of box).
• Flood detection (publish/confirm rate);
• Self-blocking queues;
• Implied Infinite loops;
• Messages that are causing exceptions in workers;