Launching SpringReactiveExampleApplication

Launch the SpringReactiveExampleApplication application class as a Java application. One of the last messages you would see in the start up log is Netty started on port(s): 8080. Netty is the default embedded server for Spring Reactive.

The following screenshot shows the browser when you navigate to the localhost:8080/stock-price.html URL:

When the Get Latest IBM Price button is clicked, EventSource kicks in and registers for events from "/stocks/price/IBM". As soon as an element is received, it is shown on the screen.

The following screenshot shows the screen after a few events are received. You can observe that an event is received every 5 seconds:

The next screenshot shows an extract from the log after the browser window is closed:

You can observe a sequence of onNext method calls, which are triggered as soon as the element is available. When the browser window is closed, the cancel() method is called to terminate the stream.

In this example, we created a controller returning an event stream (as Flux) and a web page registering to the event stream using EventSource. In the next example, let's take a look at extending the reach of an event stream to the database.

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

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