Java 9 FLow SubmissionPublisher – A Concrete Publisher
java9
6
SubmissionPublisher
1
Concrete Publisher
1
Male avatar

loveprogramming viết ngày 22/04/2021

https://grokonez.com/java/java-9/java-9-flow-submissionpublisher-concrete-publisher

Java 9 FLow SubmissionPublisher – A Concrete Publisher

JDK 9 provides a concrete Publisher named SubmissionPublisher that acts as a compliant Reactive Streams Publisher relying on drop handling and/or blocking for flow control. In this tutorial, we're gonna take a look at SubmissionPublisher and an example that generates items for Subscribers.

Related Articles:

I. Technologies

  • Java 9
  • Eclipse with Java 9 Support for Oxygen (4.7)

    II. Overview

    1. SubmissionPublisher

    SubmissionPublisher is an implementation of Java 9 Flow.Publisher that asynchronously issues items to its subscribers until closing.

Depending on usage, we can indicate the Executor for SubmissionPublisher in its constructor methods:

  • If we wanna submitting items in separate threads, and can estimate number of subscribers, consider using Executors.newFixedThreadPool(int) and constructor method:
    
    SubmissionPublisher(Executor executor, int maxBufferCapacity);
    // maxBufferCapacity: the maximum capacity for each subscriber's buffer.
    
  • Otherwise, just call the default constructor (no input parameter) that will use ForkJoinPool.commonPool().

If a Subscriber has only one action that requests and processes all items, we can consider using consume(Consumer) method (which returns a CompletableFuture object) like this:


publisher.consume((data) -> process(data));

https://grokonez.com/java/java-9/java-9-flow-submissionpublisher-concrete-publisher

Java 9 FLow SubmissionPublisher – A Concrete Publisher

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

451 bài viết.
79 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 6 tháng trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 5 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 5 tháng trước
1 0
Bài viết liên quan
Male avatar
0 0
https://grokonez.com/java/java9/java9flowapireactivestreams Java 9 Flow API – Reactive Streams Java 9 introduces Reactive Streams under java.util...
loveprogramming viết 29 ngày trước
0 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
451 bài viết.
79 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!