com.yelstream.topp.furnace.reactive.integration.StreamPublisherExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of topp-furnace-reactive-integration Show documentation
Show all versions of topp-furnace-reactive-integration Show documentation
Topp Furnace Reactive Integration provides interactions between selected reactive frameworks.
The newest version!
package com.yelstream.topp.furnace.reactive.integration;
import java.util.concurrent.Flow.*;
public class StreamPublisherExample {
public static void main(String[] args) {
java.util.stream.Stream stream = java.util.stream.Stream.of(1, 2, 3, 4, 5);
Publisher publisher = new StreamPublisher<>(stream);
publisher.subscribe(new Subscriber() {
@Override
public void onSubscribe(Subscription subscription) {
subscription.request(5); // Request all items
}
@Override
public void onNext(Integer item) {
System.out.println("Received item: " + item);
}
@Override
public void onError(Throwable throwable) {
System.err.println("Error: " + throwable.getMessage());
}
@Override
public void onComplete() {
System.out.println("Completed");
}
});
}
}