java – Performing atomic subscription operations

Question:

My task is to implement the ability to perform atomic operations to subscribe to a remote service. The service will subsequently send notifications to the open port.

There can be 1 or more such subscriptions.

I'm actually looking for a beautiful and future-expandable solution. I need to complete subscriptions to all services at the same time. If the subscription fails, then you need to unsubscribe from the hosts with which the connection was established before the failure occurs. A kind of atomic operation with the ability to rollback. Can you advise what patterns are best for this?

Answer:

Try to build logic based on Observer pattern As an example

Scroll to Top