iluwatar/java-design-patterns

Publish/Subscribe pattern

iluwatar opened this issue · 7 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.

I would like to take this issue.

Can I use Java Message Service to implement the pattern?

Sure, that should work fine

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.

Sure, let's see what you have

This issue has been automatically marked as stale because it has not had recent activity. The issue will be unassigned if no further activity occurs. Thank you for your contributions.

Hi, I would like to give this a try.
This would be my first contribution so I may need some extra help if thats ok.