Implementing the Subscriber<T> interface
Publishers cannot be executed without a Subscriber. There are a few ways to implement a subscriber and it depends on the type of publisher they are to connect to. This recipe will provide some snippets on how to instantiate a subscriber and implement its callback events.
Getting ready
This recipe will be utilizing the same ch08
to highlight the different implementation of Subscriber<T>
.
How to do it...
To render or retrieve the emitted data, a subscription API must be created. Perform the following steps on how to implement Subscriber<T>:
- Create a test class
TestEmployeeNativeStreamservice
that will verify some of the methods in the previousEmployeeNativeStreamservice
. Add the following test method that executesprocessFormUser()
usingSubscriber<T>
implemented throughjava.util.function.Consumer<T>
:
@RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration(classes = { SpringDbConfig.class, SpringDispatcherConfig...