Skip to content

Conversation

@luismr
Copy link
Owner

@luismr luismr commented May 8, 2025

Pull Request: Implement Decoupled WebSocket Events Publisher with Kafka

Summary

This PR implements a decoupled architecture for WebSocket event publishing using Kafka as the message broker. The changes enable distributed WebSocket notifications across multiple server instances, improve message handling reliability, and add comprehensive test coverage.

Changes

  • Added Kafka-based event publishing for PingCreated events
  • Implemented Kafka consumer for WebSocket message distribution
  • Added configuration toggles for WebSocket and Kafka features
  • Added comprehensive test coverage for event publishing and consumption
  • Improved error handling and message validation
  • Updated documentation and configuration properties
  • Added architectural diagrams for load balancing

Motivation

  • Enable horizontal scaling of WebSocket servers by decoupling event publishing from WebSocket delivery
  • Improve reliability of message delivery across multiple server instances
  • Allow for better control over feature toggles through configuration
  • Ensure proper test coverage for critical messaging components
  • Provide better error handling and message validation
  • Document the new architecture and its benefits

Checklist

  • Code follows Java best practices and coding standards
  • Added proper documentation for new classes and methods
  • Updated existing documentation to reflect changes
  • All tests are passing
  • No new warnings or errors in the build
  • Changes are properly formatted according to project style guide
  • Added appropriate logging for debugging purposes
  • Configuration is properly externalized through properties
  • Kafka consumer configuration follows best practices
  • Proper error handling is in place
  • Code is properly modularized and follows SOLID principles
  • No hardcoded values in the configuration
  • Proper use of dependency injection
  • Appropriate use of Spring annotations and configuration
  • WebSocket session management is thread-safe
  • Virtual threads are properly configured for WebSocket operations
  • Message serialization/deserialization is properly handled
  • Feature toggles are properly implemented
  • Added test coverage for all new components
  • Updated architectural documentation
  • Added load balancing diagram
  • Proper handling of null/empty messages
  • Proper cleanup of WebSocket sessions
  • Proper error handling for WebSocket message delivery
  • Proper configuration of Kafka consumer groups
  • Proper handling of transaction boundaries
  • Proper use of Spring's event system

@luismr luismr merged commit ef4f7d7 into main May 8, 2025
1 check passed
@luismr luismr deleted the feature/decoupled-websocket-events-publisher branch May 8, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants