Skip to content

ahmedbaw/msgq-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Message Queue

Introduction

Message queues are a component of distributed system that facilitates communication between different parts of the system. They allow messages to be sent from a producer to a consumer in an asynchronous manner.

Local Image

Key aspects:

  1. Asynchronous Communication
    Producers and consumers do not have to communicate directly. Instead, producers push messages to a queue, and consumers retrieve them at their own pace.
  2. Decoupling
    Message queues decouple different parts of an application, allowing them to operate independently and be developed, deployed and scaled separately.
  3. Message storage
    Messages are stored in the queue until they are retrieved by the consumer. This allows the messages to be preserved even if the consumer is not available.
  4. Reliability
    Message queues provide mechanisms to ensure reliable message delivery, such as message acknowledgements, retries, and dead-letter queues for handling failed messages.
  5. Load balancing
    By distributing the load among multiple consumers, message queues can help balance the load to improve the performance of the application.

Types:

  1. Point-to-Point (P2P)
    In this model, a message is sent from the producer to a specific consumer. Once the message is consumed, it is deleted from the queue. This is suitable for tasks that involve a single recipient, such as task distribution and job processing.
  2. Publish-Subscribe (Pub/Sub)
    In this model, messages are broadcast to a topic and multiple subscribers can receive the same message. This is ideal for scenarios like notifications and real-time updates.

Use Cases:

  • Job Processing
    Message queues are used to distribute tasks to worker processes, ensuring that tasks are processed asynchronously and can be scaled horizontally.
  • Event-Driven Architectures
    In microservices architectures, message queues enable services to communicate asynchronously and to react to events generated by other services.
  • Load Balancing
    Queues help distribute loads among multiple consumers, improving the systems' performance.
  • Data Ingestion
    In data processing pipelines, message queues can buffer incoming data, ensuring a smooth and reliable data ingestion even during spikes in data throughput.

About

Message Queue written in Typescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published