The reactive approach

Reactive approaches involve connecting the different components involved to be able to react to events as they occur.

When the stock price web page is loaded, the web page registers for events from the stock price service. When the stock price change event occurs, an event is triggered. The latest stock price is updated on the web page. The following sequence diagram shows the reactive approach of building the stock price page:

The reactive approach typically involves three steps:

  1. Subscribing to events.
  2. Occurrence of events.
  3. Unregistering.

When the stock price web page is initially loaded, it will subscribe to the stock price change event. The way you subscribe is different based on the reactive framework and/or the message broker (if any) that you use.

When the stock price change event for a specific stock occurs, a new event is triggered for all the subscribers of the event. The listener ensures that the web page is updated with the latest stock price.

Once the web page is closed (or refreshed), an unregister request is sent out by the subscriber.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset