java-design-patterns icon indicating copy to clipboard operation
java-design-patterns copied to clipboard

Publish/Subscribe pattern

Open iluwatar opened this issue 3 months ago • 5 comments

Introduce the Publish/Subscribe pattern to provide a flexible event-handling system.

The Publish/Subscribe pattern is a messaging paradigm used in software architecture with several key points:

  • Decoupling of publishers and subscribers: Publishers and subscribers operate independently, and there's no direct link between them. This enhances the scalability and modularity of applications.

  • Event-driven communication: The pattern facilitates event-driven architectures by allowing publishers to broadcast events without concerning themselves with who receives the events.

  • Dynamic subscription: Subscribers can dynamically choose to listen for specific events or messages they are interested in, often by subscribing to a particular topic or channel.

  • Asynchronous processing: The pattern inherently supports asynchronous message processing, enabling efficient handling of events and improving application responsiveness.

  • Scalability: By decoupling senders and receivers, the pattern can support a large number of publishers and subscribers, making it suitable for scalable systems.

  • Flexibility and adaptability: New subscribers or publishers can be added to the system without significant changes to the existing components, making the system highly adaptable to evolving requirements.

Acceptance Criteria:

  • The implementation must follow the project's coding standards and directory structure as outlined in the contribution guidelines.
  • Comprehensive unit tests must cover the new pattern implementation, ensuring all major use cases are accounted for.
  • Documentation must be provided, explaining the pattern, its use cases, and how the implementation solves a particular problem, including UML diagrams where applicable.

iluwatar avatar Apr 07 '24 08:04 iluwatar

I would like to take this issue.

Ehspresso avatar Apr 10 '24 20:04 Ehspresso

Can I use Java Message Service to implement the pattern?

Ehspresso avatar Apr 11 '24 18:04 Ehspresso

Sure, that should work fine

iluwatar avatar Apr 11 '24 19:04 iluwatar

I have an implementation of the pattern. However I am finding it difficult to test since the implementation is quite basic given the asynchronous/threading code is handled by JMS which shouldn't be tested since its a third party software. I can create a pull request and the current tests can be viewed, perhaps you'll find it satisfactory. If not, I am happy to receive criticism to improve my testing, it can improve my knowledge.

Ehspresso avatar Apr 16 '24 19:04 Ehspresso

Sure, let's see what you have

iluwatar avatar Apr 17 '24 17:04 iluwatar