n our custom Subscriber implementation, we do the following:
Our subscriber has to hold a reference to a Subscription that binds a Publisher and our Subscriber. As subscription and data processing may happen in different threads, we use the volatile keyword to make sure that all threads will have the correct reference to the Subscription instance.
When a subscription arrives, our Subscriber is informed with the onSubscribe callback. Here, we save the subscription (2.1) and request the initial demand (2.2). Without that request, a TCK complaint provider will not be allowed to send data and elements processing will not start at all.
In the onNext callback, we log the received data and request the next element. In this case, we use a straightforward pull model (subscription.request(1)) for backpressure management.
Here, we generate a simple stream with the just factory method.
Here, we subscribe our custom subscriber to the Reactive Stream defined in step