Skip to content

Latest commit

 

History

History
181 lines (135 loc) · 5.51 KB

File metadata and controls

181 lines (135 loc) · 5.51 KB

STOMP Protocol Server-Client Implementation

A full-featured implementation of the STOMP (Simple Text Oriented Messaging Protocol) messaging system with a multi-threaded Java server and C++ client, demonstrating advanced systems programming concepts.

🎯 Project Overview

This project implements a complete publish-subscribe messaging system using the STOMP protocol, featuring:

  • Multi-threaded Java Server: Handles concurrent client connections with thread-safe state management
  • C++ Client: Dual-threaded architecture for simultaneous keyboard input and socket communication
  • Protocol Compliance: Full STOMP 1.2 frame parsing and command implementation
  • Cross-language Integration: Demonstrates interoperability between Java and C++ systems

🏗️ Architecture

Server (Java)

  • Connection Management: Thread-safe ConcurrentHashMap for managing active client sessions
  • Protocol Handler: Complete STOMP command processing (CONNECT, SUBSCRIBE, SEND, UNSUBSCRIBE, DISCONNECT)
  • Authentication: Integrated user authentication system
  • Topic-based Messaging: Efficient pub-sub pattern implementation

Client (C++)

  • Two-threaded Design:
    • Keyboard Thread: Non-blocking user input processing
    • Socket Thread: Asynchronous server communication
  • Protocol Encoding: StompProtocol class for frame conversion and response handling
  • File Tracking: Advanced event file parsing and game summary tracking
  • C++11 Compliant: Follows modern C++ standards for portability

🛠️ Technical Highlights

Concurrency & Thread Safety

  • Implemented thread-safe shared state using ConcurrentHashMap
  • Designed lock-free message passing between client threads
  • Handled race conditions in subscription management

Network Programming

  • Low-level socket programming in both Java and C++
  • Custom protocol frame parsing with string manipulation
  • Efficient binary data transmission

Systems Integration

  • Cross-language socket communication
  • JSON parsing for event data
  • Standard I/O handling and redirection

📋 Requirements

Server

  • Java 11 or higher
  • Gradle build system

Client

  • C++11 compiler (g++ 4.8+ or clang 3.3+)
  • Boost libraries (for networking)
  • Make build system

🚀 Getting Started

Building the Server

cd server
gradle build

Building the Client

cd client
make

Running the Server

java -jar server/build/libs/server.jar <port>

Running the Client

./bin/StompClient <host> <port>

📝 STOMP Commands Supported

Command Description
CONNECT Establish connection with authentication
SUBSCRIBE Subscribe to a topic/destination
SEND Publish message to a topic
UNSUBSCRIBE Unsubscribe from a topic
DISCONNECT Gracefully close connection

🔧 Key Implementation Details

Server-Side Frame Processing

  • Validates frame headers and required fields
  • Maintains per-client subscription state
  • Broadcasts messages to all topic subscribers
  • Handles graceful disconnection and cleanup

Client-Side Event Handling

  • Parses JSON event files for game data
  • Tracks sent events to prevent duplicates
  • Displays server responses with proper formatting
  • Implements keyboard shortcuts for common operations

📊 Project Structure

.
├── server/
│   ├── src/
│   │   └── main/
│   │       └── java/
│   │           └── bgu/spl/net/
│   │               ├── impl/
│   │               │   ├── ConnectionsImpl.java
│   │               │   └── ...
│   │               └── srv/
│   │                   └── ...
│   └── build.gradle
├── client/
│   ├── src/
│   │   ├── StompClient.cpp
│   │   ├── StompProtocol.cpp
│   │   └── ...
│   ├── include/
│   │   ├── StompProtocol.h
│   │   └── ...
│   └── Makefile
└── README.md

🎓 Learning Outcomes

This project demonstrates proficiency in:

  • Systems Programming: Low-level socket programming and system calls
  • Concurrent Programming: Multi-threading and synchronization
  • Network Protocols: Protocol design and implementation
  • Cross-Platform Development: Java and C++ integration
  • Software Architecture: Clean separation of concerns and modularity

🐛 Known Issues & Solutions

C++11 Compatibility

Ensured all C++ code conforms to C++11 standard (no C++14/17 features) for maximum compatibility.

MESSAGE Frame Duplication

Implemented tracking mechanism to prevent duplicate MESSAGE headers in SEND commands.

Thread Safety

Resolved race conditions in subscription management through proper use of concurrent data structures.

📚 Technologies Used

  • Languages: Java, C++
  • Build Tools: Gradle, Make
  • Libraries: Boost (C++), Java Concurrency Utilities
  • Protocol: STOMP 1.2
  • Data Format: JSON (event files)

👨‍💻 Development Process

Developed as part of Systems Programming Language (SPL) coursework, this project follows industry best practices:

  • Git version control with meaningful commits
  • Incremental feature development
  • Systematic debugging and testing
  • Code review and refactoring

📄 License

This project was developed for academic purposes as part of a university assignment.


Note: This implementation showcases fundamental systems programming concepts and is intended for educational purposes and portfolio demonstration.