Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

The publisher classes

We need four classes to implement the Flow.Publisher and the Flow.Subscription interfaces. The first one is the MySubscription class that implements the Flow.Subscription interface. We are going to store three attributes in this class:

The canceled attribute: A Boolean value that indicates if the subscription is cancelled or not

The requested attribute: An AtomicLong value that stores the number of news items that have been requested by the consumer

The categories attribute: A Set of Integer values that stores the categories of the news associated with this subscription