java.util.concurrent.Flow.Subscription Java Examples
The following examples show how to use
java.util.concurrent.Flow.Subscription.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: servicetalk Author: apple File: JdkFlowAdaptersTest.java License: Apache License 2.0 | 6 votes |
private Publisher<Integer> newMockFlowPublisher( BiConsumer<Subscriber<? super Integer>, Subscription> subscriberTerminator) { @SuppressWarnings("unchecked") Publisher<Integer> flowPublisher = mock(Publisher.class); doAnswer(invocation -> { Subscriber<? super Integer> subscriber = invocation.getArgument(0); Subscription subscription = mock(Subscription.class); doAnswer(invocation1 -> { subscriberTerminator.accept(subscriber, subscription); return null; }).when(subscription).request(anyLong()); subscriber.onSubscribe(subscription); return null; }).when(flowPublisher).subscribe(any()); return flowPublisher; }
Example #2
Source Project: clouditor Author: clouditor File: Subscriber.java License: Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Subscription subscription) { this.subscription = subscription; LOGGER.info("Successfully subscribed to publisher."); this.subscription.request(1); }
Example #3
Source Project: Java-Concurrency-Multithreading-in-Practice Author: PacktPublishing File: Lesson4.java License: MIT License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println(name + " subscribed!"); this.subscription = subscription; subscription.request(1); }
Example #4
Source Project: servicetalk Author: apple File: JdkFlowAdaptersTest.java License: Apache License 2.0 | 5 votes |
@Test public void toFlowCancel() { TestPublisher<Integer> stPublisher = new TestPublisher<>(); Subscriber<Integer> subscriber = toFlowPublisherAndSubscribe(stPublisher); TestSubscription subscription = new TestSubscription(); stPublisher.onSubscribe(subscription); assertThat("Source not subscribed.", stPublisher.isSubscribed(), is(true)); ArgumentCaptor<Subscription> subscriptionCaptor = ArgumentCaptor.forClass(Subscription.class); verify(subscriber).onSubscribe(subscriptionCaptor.capture()); subscriptionCaptor.getValue().cancel(); assertThat("Subscription not cancelled.", subscription.isCancelled(), is(true)); }
Example #5
Source Project: servicetalk Author: apple File: JdkFlowAdaptersTest.java License: Apache License 2.0 | 5 votes |
@Test public void toFlowFromSourceCancel() { PublisherSource.Subscription srcSubscription = mock(PublisherSource.Subscription.class); PublisherSource<Integer> source = s -> s.onSubscribe(srcSubscription); Subscriber<Integer> subscriber = toFlowPublisherFromSourceAndSubscribe(source); ArgumentCaptor<Subscription> flowSubscriptionCaptor = ArgumentCaptor.forClass(Subscription.class); verify(subscriber).onSubscribe(flowSubscriptionCaptor.capture()); flowSubscriptionCaptor.getValue().cancel(); verify(srcSubscription).cancel(); }
Example #6
Source Project: servicetalk Author: apple File: JdkFlowAdaptersTest.java License: Apache License 2.0 | 5 votes |
private Subscriber<Integer> subscribeToFlowPublisher(final Publisher<Integer> flowPublisher) { @SuppressWarnings("unchecked") Subscriber<Integer> subscriber = mock(Subscriber.class); flowPublisher.subscribe(subscriber); ArgumentCaptor<Subscription> subscriptionCaptor = ArgumentCaptor.forClass(Subscription.class); verify(subscriber).onSubscribe(subscriptionCaptor.capture()); subscriptionCaptor.getValue().request(1); return subscriber; }
Example #7
Source Project: java-async-util Author: IBM File: FlowAdapter.java License: Apache License 2.0 | 5 votes |
@Override public void onSubscribe(final Flow.Subscription subscription) { Objects.requireNonNull(subscription); if (this.subscription != null) { subscription.cancel(); return; } this.subscription = subscription; }
Example #8
Source Project: pgadba Author: pgjdbc File: Examples.java License: BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { group = session.<Long, Long>operationGroup() .independent() .collect(Collectors.summingLong(c -> c)); group.submit(); session.requestHook(subscription::request); }
Example #9
Source Project: pgadba Author: pgjdbc File: Examples.java License: BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { ds = factory.builder() .url("//host.oracle.com:5521/example") .username("scott") .password("tiger") .requestHook(subscription::request) .build(); }
Example #10
Source Project: pgadba Author: pgjdbc File: BackPressureTest.java License: BSD 2-Clause "Simplified" License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { log("Subscribed"); this.subscription = subscription; requestItems(demand); }
Example #11
Source Project: javase Author: critoma File: ProgMainReactiveStreamsWithProcessor.java License: MIT License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println("Subscribed"); this.subscription = subscription; this.subscription.request(1); //requesting data from publisher System.out.println("onSubscribe requested 1 item"); }
Example #12
Source Project: javase Author: critoma File: ProgMainReactiveStreamsWithProcessor.java License: MIT License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println("Subscribed for Freelancer"); this.subscription = subscription; this.subscription.request(1); //requesting data from publisher System.out.println("onSubscribe requested 1 item for Freelancer"); }
Example #13
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Stream.java License: GNU General Public License v2.0 | 5 votes |
@Override public void onSubscribe(Flow.Subscription subscription) { if (this.subscription != null) { throw new IllegalStateException(); } this.subscription = subscription; subscription.request(1); }
Example #14
Source Project: demo-java-x Author: CodeFX-org File: LoggingRandomDelaySubscriber.java License: MIT License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { log("Subscribed..."); this.subscription = subscription; this.buffer = new AtomicInteger(); requestItems(); }
Example #15
Source Project: journaldev Author: journaldev File: MyFreelancerSubscriber.java License: MIT License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println("Subscribed for Freelancer"); this.subscription = subscription; this.subscription.request(1); //requesting data from publisher System.out.println("onSubscribe requested 1 item for Freelancer"); }
Example #16
Source Project: journaldev Author: journaldev File: MySubscriber.java License: MIT License | 5 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println("Subscribed"); this.subscription = subscription; this.subscription.request(1); //requesting data from publisher System.out.println("onSubscribe requested 1 item"); }
Example #17
Source Project: enmasse Author: EnMasseProject File: AbstractClient.java License: Apache License 2.0 | 5 votes |
private void setLinkAttachedProbe() { var linkAttachedProbe = linkAttachedProbeFactory().get(); executor.setStdErrProcessor(new Subscriber<String>() { @Override public void onSubscribe(Subscription subscription) { //empty } @Override public void onNext(String item) { if (!linkAttached.isDone()) { if (linkAttachedProbe.test(item)) { log.info("Client is attached!!"); linkAttached.complete(null); } } } @Override public void onError(Throwable throwable) { linkAttached.completeExceptionally(throwable); } @Override public void onComplete() { linkAttached.complete(null); } }); }
Example #18
Source Project: Java-Concurrency-Multithreading-in-Practice Author: PacktPublishing File: Lesson4.java License: MIT License | 4 votes |
@Override public void onSubscribe(Flow.Subscription subscription) { this.subscription = subscription; subscription.request(1); }
Example #19
Source Project: Java-Concurrency-Multithreading-in-Practice Author: PacktPublishing File: Lesson4.java License: MIT License | 4 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println(name + " subscribed!"); this.subscription = subscription; subscription.request(1); }
Example #20
Source Project: Java-Concurrency-Multithreading-in-Practice Author: PacktPublishing File: Lesson3.java License: MIT License | 4 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println(name + " subscribed!"); this.subscription = subscription; subscription.request(1); }
Example #21
Source Project: Java-Concurrency-Multithreading-in-Practice Author: PacktPublishing File: Lesson3.java License: MIT License | 4 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.println(name + " subscribed!"); this.subscription = subscription; subscription.request(1); }
Example #22
Source Project: conga Author: FIXTradingCommunity File: Trader.java License: Apache License 2.0 | 4 votes |
@Override public void onSubscribe(Subscription subscription) { Trader.this.subscription = subscription; request(1); }
Example #23
Source Project: conga Author: FIXTradingCommunity File: TraderTest.java License: Apache License 2.0 | 4 votes |
@Override public void onSubscribe(Subscription subscription) { this.subscription = subscription; }
Example #24
Source Project: servicetalk Author: apple File: JdkFlowAdapters.java License: Apache License 2.0 | 4 votes |
@Override public void onSubscribe(final PublisherSource.Subscription subscription) { subscriber.onSubscribe(new Subscription() { @Override public void request(final long n) { subscription.request(n); } @Override public void cancel() { subscription.cancel(); } }); }
Example #25
Source Project: servicetalk Author: apple File: JdkFlowAdapters.java License: Apache License 2.0 | 4 votes |
FlowToSTSubscription(final Subscription s) { this.s = s; }
Example #26
Source Project: servicetalk Author: apple File: JdkFlowAdapters.java License: Apache License 2.0 | 4 votes |
@Override public void onSubscribe(final Subscription s) { subscriber.onSubscribe(new FlowToSTSubscription(s)); }
Example #27
Source Project: java-async-util Author: IBM File: FlowAdapterTest.java License: Apache License 2.0 | 4 votes |
@Override public void onSubscribe(final Subscription arg0) { this.subscription = arg0; this.subscription.request(1); }
Example #28
Source Project: java-async-util Author: IBM File: AdaptedWhiteBoxSubscriberVerificationTest.java License: Apache License 2.0 | 4 votes |
@Override protected Subscriber<Integer> createFlowSubscriber( final WhiteboxSubscriberProbe<Integer> probe) { final Subscriber<Integer> backing = new FlowAdapter.SubscribingIterator<>(); return new Subscriber<Integer>() { @Override public void onSubscribe(final Subscription s) { backing.onSubscribe(s); probe.registerOnSubscribe(new SubscriberPuppet() { @Override public void triggerRequest(final long elements) { s.request(elements); } @Override public void signalCancel() { s.cancel(); } }); } @Override public void onNext(final Integer integer) { backing.onNext(integer); probe.registerOnNext(integer); } @Override public void onError(final Throwable throwable) { backing.onError(throwable); probe.registerOnError(throwable); } @Override public void onComplete() { backing.onComplete(); probe.registerOnComplete(); } }; }
Example #29
Source Project: pgadba Author: pgjdbc File: BackPressureTest.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public void onSubscribe(Subscription subscription) { this.subscription = subscription; this.subscription.request(1); }
Example #30
Source Project: javase Author: critoma File: ProgMainReactiveStreams.java License: MIT License | 4 votes |
@Override public void onSubscribe(Subscription subscription) { System.out.printf("new subscription %s\n", subscription); this.subscription = subscription; subscription.request(1); }