{"id":27933095,"url":"https://github.com/gireeshbharmshetty/java-message-queue","last_synced_at":"2025-05-07T04:27:23.322Z","repository":{"id":291411063,"uuid":"977537012","full_name":"gireeshbharmshetty/java-message-queue","owner":"gireeshbharmshetty","description":"A simple, thread-safe, in-memory blocking message queue in Java.","archived":false,"fork":false,"pushed_at":"2025-05-04T12:42:34.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-04T13:46:07.460Z","etag":null,"topics":["blocking-queue","concurrency","java","message-queue","producer-consumer","system-design"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gireeshbharmshetty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-04T12:41:44.000Z","updated_at":"2025-05-04T12:43:19.000Z","dependencies_parsed_at":"2025-05-04T13:56:17.632Z","dependency_job_id":null,"html_url":"https://github.com/gireeshbharmshetty/java-message-queue","commit_stats":null,"previous_names":["gireeshbharmshetty/java-message-queue"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gireeshbharmshetty%2Fjava-message-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gireeshbharmshetty%2Fjava-message-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gireeshbharmshetty%2Fjava-message-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gireeshbharmshetty%2Fjava-message-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gireeshbharmshetty","download_url":"https://codeload.github.com/gireeshbharmshetty/java-message-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252812558,"owners_count":21808161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blocking-queue","concurrency","java","message-queue","producer-consumer","system-design"],"created_at":"2025-05-07T04:27:22.738Z","updated_at":"2025-05-07T04:27:23.309Z","avatar_url":"https://github.com/gireeshbharmshetty.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java In-Memory Blocking Message Queue\n\n## Project Overview\n\nThis project provides a simple, thread-safe, in-memory message queue implementation in Java. It demonstrates the producer-consumer pattern using a fixed-size buffer (the queue) and blocking operations.\n\n## How it Works\n\nThis implementation leverages Java's built-in `java.util.concurrent.BlockingQueue` interface, specifically using `LinkedBlockingQueue`.\n\n*   **Bounded Capacity:** The queue is initialized with a fixed maximum capacity.\n*   **Blocking Operations:**\n    *   `produce(message)`: Uses the `put()` method of `BlockingQueue`. If the queue is full, the calling producer thread will block (wait) until space becomes available.\n    *   `consume()`: Uses the `take()` method of `BlockingQueue`. If the queue is empty, the calling consumer thread will block (wait) until a message is available.\n*   **Thread Safety:** `LinkedBlockingQueue` is inherently thread-safe, handling all the necessary synchronization internally.\n*   **FIFO:** Messages are consumed in the First-In, First-Out order they were produced.\n\n## Benefits \u0026 Relevance\n\n*   **Producer-Consumer Pattern:** Demonstrates a fundamental concurrency pattern used in many distributed systems and applications.\n*   **Concurrency Practice:** Provides practical application of Java's concurrent collections (`BlockingQueue`) and thread management (`ExecutorService`).\n*   **System Design Insight:** Helps understand the basics of message queuing systems, which are crucial components in decoupling services and managing asynchronous communication.\n*   **Interview Relevance:** Concepts like blocking queues, thread safety, and producer-consumer are common topics in software engineering interviews, particularly for backend and systems roles.\n\n## How to Use/Run\n\n1.  **Compile:** Compile the Java files using a Java Development Kit (JDK):\n    ```bash\n    javac src/main/java/com/gireesh/queue/*.java\n    ```\n2.  **Run the Demo:** Execute the `MessageQueueDemo` class to see multiple producers and consumers interacting with the queue:\n    ```bash\n    java -cp src/main/java com.gireesh.queue.MessageQueueDemo\n    ```\n    The demo simulates producers adding messages and consumers removing them concurrently, showing how the queue size changes and how threads block when the queue is full or empty.\n\n## Files\n\n*   `src/main/java/com/gireesh/queue/MessageQueue.java`: The interface defining the basic queue operations.\n*   `src/main/java/com/gireesh/queue/InMemoryBlockingMessageQueue.java`: The concrete implementation using `LinkedBlockingQueue`.\n*   `src/main/java/com/gireesh/queue/MessageQueueDemo.java`: A demonstration class showing concurrent producers and consumers.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgireeshbharmshetty%2Fjava-message-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgireeshbharmshetty%2Fjava-message-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgireeshbharmshetty%2Fjava-message-queue/lists"}