Code Monkey home page Code Monkey logo

message-queue's Introduction

Message Queue System

Overview

This is a simple implementation of a message queue system that allows publishers to send messages to a queue, and subscribers to consume messages from the queue. The system supports multiple subscribers with the ability to process messages based on patterns.

Components

MessageQueue

The MessageQueue class is the core component that manages the message queue. It handles message publishing, message dequeueing, and message expiration. It also includes a cleaner worker to remove expired messages.

MessagePublisher

The MessagePublisher class represents a publisher that can publish messages to the message queue. It uses a unique ID and name for identification.

MessageSubscriber

The MessageSubscriber class represents a subscriber that can consume messages from the message queue. It includes the ability to subscribe to specific patterns and process messages accordingly.

SubscriberWorker

The SubscriberWorker class is a worker thread associated with each subscriber. It continuously consumes messages from the message queue and processes them.

DeadLetterQueue

The DeadLetterQueue class is responsible for managing messages that exceed the maximum retry count. These messages are moved to the dead-letter queue.

JsonMessageProcessor

The JsonMessageProcessor class is an example implementation of a message processor. It processes JSON messages received by subscribers.

Other Classes

  • JsonMessage: Represents a JSON message in the system.
  • JsonPayload: Represents the payload of a JSON message.
  • CleanerWorker: Handles the periodic cleaning of expired messages from a queue.
  • SimpleLogger: Provides a simple logging mechanism for the system.

Usage

To use the message queue system, you can create instances of MessagePublisher and MessageSubscriber. Publishers can publish messages, and subscribers can subscribe to specific patterns and process messages accordingly.

Testing

The system includes test classes for various components, including MessageSubscriberTest, MessagePublisherTest, and MessageQueueTest. These tests cover different scenarios to ensure the correctness of the implementation.

Dependencies

The system uses Java with the following dependencies:

  • Lombok: Simplifies Java boilerplate code.
  • JUnit: Used for unit testing.

Building and Running

The project can be built using your favorite build tool (e.g., Maven or Gradle). Ensure that the dependencies are resolved, and run the tests to verify the functionality.

message-queue's People

Contributors

coderocker avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.