1. Introduction
This report presents the design, implementation, and validation of three distributed applications developed using RabbitMQ as the middleware to enable asynchronous message-based communication. The applications—Chatting Application, Trading System, and Contact Tracing System—demonstrate various use cases, including real-time chat, stock trading, and contact tracing in a grid-based environment. Each application includes both a command-line interface (CLI) and a graphical user interface (GUI) to enhance functionality and user experience.
REPORT:
2. Task 1: Chatting Application
2.1 Overview
The Chatting Application allows multiple users to exchange messages within virtual chat rooms. Each user selects a chat room upon login, ensuring that messages are only shared among participants in the same room. This task demonstrates topic-based messaging and real-time communication.
2.2 Design and Architecture
- Middleware: RabbitMQ is used as the message broker to manage message distribution within rooms. Each chat room corresponds to a separate fanout exchange in RabbitMQ.
- Topic-Based Messaging: Each room has its own exchange, which isolates conversations and allows only users in the same room to receive messages.
- Components:
- CLI Client: Handles user input and prints messages to the console, based on the selected room.
- GUI Client: Provides a graphical login screen and chat interface with real-time message display.
- Message Flow:
- Publish: Users send messages to the room’s exchange.
- Subscribe: Each user creates an exclusive queue bound to the exchange, receiving messages only for the room they joined.
2.3 Code Implementation
- CLI Version: The CLI version takes username and room as input arguments. After starting, it subscribes to the specified room’s exchange, receiving and displaying messages in real-time.
- Room-based Isolation: Each room has its own RabbitMQ exchange, ensuring messages are isolated by room.
- Message Format: Messages are sent in the format <username>: <message>, making it easy to identify the sender.
- Error Handling: Ensures valid input for username and room, with error messages guiding the user.
2.4 GUI Features
- User Login Screen: Provides input fields for username and room selection. Users are prompted to enter valid details before joining the chat.
- Chat Interface:
- Chat Display Area: Shows incoming messages in a scrollable text box.
- Message Input: Allows users to send messages to the room by typing in an entry field.
- Room Isolation: When users select a room, they only see messages from that room, ensuring a seamless user experience.