Java 9 Flow API example – Processor
Java
215
java9
12
flow
2
processor
1
Male avatar

loveprogramming viết ngày 19/05/2021

https://grokonez.com/java/java-9/java-9-flow-api-example-processor

Java 9 Flow API example – Processor

In previous post, we have general knowledge about Reactive Streams and Java 9 Flow API Components and Behaviour. In this tutorial, we're gonna look at an example that implements Publisher, Subscriber with Processor as a bridge for reactive programming.

Related Articles:

I. Technologies

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

    II. Overview

    1. Processor

    A Processor is a component that sits between the Publisher and Subscriber. It acts as:
  • a Subscriber when emitting a request signal to Publisher
  • a Publisher when pushing items to Subscriber.

We can create one or more Processors in chain which link a Publisher to a Subscriber.
reactive-stream-pubisher-processer-subscriber

2. Project

We will create a Publisher that is subscribed by a Processor, and that Processor will publish data to a Subscriber.

  • Publisher define a Subscription to work with Processor.
  • Processor define its own Subscription to work with Subscriber.

  • Using Subscriber::onNext() method, Publisher pushes items to Processor, and Processor pushes items to Subscriber.

  • Using Subscription::request() method, Processor requests items from Publisher, and Subscriber requests items from Processor.

  • Publisher and Processor defines an Executor for multi-threading. Then request() and onNext() method work asynchronously.

  • Processor has a data buffer to store items in case the demand number of items requested by Subscriber and Processor are different.

    III. Practice

    To understand how Publisher, Subscriber, Subscription and Processor behave and way to implementing them, please visit: Java 9 Flow API – Reactive Streams

Publisher<Integer> ------ Processor<Integer, String> ------ Subscriber<String>

More at:

https://grokonez.com/java/java-9/java-9-flow-api-example-processor

Java 9 Flow API example – Processor

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

545 bài viết.
97 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 9 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 7 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 7 tháng trước
1 0
Bài viết liên quan
White
2 0
Trong bài viết này, một số hình ảnh hoặc nọi dung có thể bị thiếu do quá trình chế bản. Vui lòng xem nội dung ở blog gốc sau: (Link) (Link), chúng...
programmerit viết gần 6 năm trước
2 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

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


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
545 bài viết.
97 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á!