好文集ChatGPT Plus¥119

Queues vs Streams vs Pub/Sub

文章目录

If you are working with or want to learn event-driven architecture it’s important to know the difference between queues, streams and pub/sub. At a glance they may look similar but they are completely different.

Here are the differences and I also added some links so you can dive deeper if you want to learn more. Hope it helps!

Queues

  • Messages are put onto a queue and consumers consume the message to process them.

  • Messages are acknowledged as they are consumed and deleted after they a processed.

  • Messages can be consumed by many consumers giving you the ability to process messages in parallel also known as Competing Consumers (as seen in the Enterprise Integration Patterns).

  • An real-world example of this would be queuing at the shops. You stand in one big queue (message queue) with one cashier (consumer), that cashier is processing each shopper (message). Shops open up more cashiers (consumers) to help with the customers (messages). Similar thought process with channels, messages and queues.

  • Explore the “Point-to-point messaging” visual to dive into messaging patterns.

Streams

Pub/Sub (Publish/Subscribe)

Extra Resources

全文完
查看原文