什麼是 Message Queue
Message Queue 是一種非同步的從一個服務到另一個服務的交流形式, 被用於無伺服器架構和微服務架構中。
Messages 被儲存在一個佇列中直到被處理了或被刪除。
每個Messages只會被唯一的Consumer處理一次.
Message Queue can be used to decouple heavyweight processing, to buffer or batch work, and to smooth spiky workloads.
Message Queue Basics
In modren cloud architecture, applications are decoupled into smaller, independent building blocks that are easier to develop, deploy and maintain.
Message Queue provides communication and coordinate for these distributed applications; therefore, Message Queue can signicantly simplify coding of decoupled applications, while improving performance, reliability and scalability.
Message Queue allow different parts of a system to comunication and process operations asynchronously.
A Message Queue provides a lightweight buffer to temporarily stores messages and endpoints, so that components can connect to the queue in order to send and receive messages. The messages are usually small, and can be things like requests, replies, error messages, or just plain information.
To send a message, a components called a producer adds a message to the queue. The message is stored on the queue until another components called consumer retrieves the message and does something with it.
Many producers and consumers can use the queue, but each message can only be processed once, by a single consumer. For this reason, this messaging pattern is often called one-to-one, or point-to-point, comunications.
When a message needs to be processed more than one consumer, Message queue can be conbined with Publish / Subscribe messaging in a fanout design pattern.