일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- java bigdecimal
- codedeploy
- VPN
- aws
- JavaScript
- Kafka
- Airflow
- PostgreSQL
- docker
- Python
- 도커
- aws cicd
- or some instances in your deployment group are experiencing problems.
- chart.js
- kubeflow
- codepipeline
- COALESCE
- Jenkins
- node
- AWS CI/CD 구축하기
- Flux
- bootstrap
- codebuild
- Spring
- IntelliJ
- Spring Error
- chartjs
- redis
- codedeploy error
- SQL
- Today
- Total
Small Asteroid Blog
Reactive Streams 본문
Reactive Streams
Reactive Streams 는 논블로킹 백프레셔를 이용한 비동기 데이터 스트림 처리 표준이다.
Reactive Streams 을 사용하는 주목적은 Subscriber가 Publisher의 생산 속도를 제어하는 것이다.
Reactive Streams 에는 네 가지 인터페이스가 있다.
- Publisher
- 데이터를 생성하고 내보낸다.
- Subscriber
- 데이터를 구독하고 통지 받은 데이터를 처리한다.
- Subscription
- Publisher, Subscriber 간에 데이터가 교환될 수 있도록 연결하는 역할을 하며, 전달 받을 데이터의 개수를 요청하고 구독을 해지한다.
- Processor
- Publisher, Subscriber 모두 상속받은 인터페이스이다.
Reactive Streams 흐름 이해하기
Subscriber가 subscribe 를 호출하는 순간 Publisher 에서 Subscriber로 데이터가 전달이 시작된다.
Subscriber 가 Publisher 에게 subscribe 하면 Publisher 가 데이터(시퀀스)를 전달한다.
데이터(시퀀스)를 전달하기 전에 Subscription이 onSubscribe()를 호출하고
Subscriber 는 request(n)를 호출하여 몇개의 데이터를 보내달라고 요청한다.
이 과정에서 에러가 발생하면 onError()를 호출하고
데이터(시퀀스) 전달이 완료가 되면 onComplete()를 호출한다.
Subscriber 가 Publisher 에 Request 하는 과정을 보통 Back-Pressure 라고 한다.
Back-Pressure는 Push하는 데이터(시퀀스)의 흐름을 제어할 수 있다.
아래 코드는 Reactive Streams 에 정의된 코드이다.
public interface Processor<T, R> extends Subscriber<T>, Publisher<R> {}
public interface Publisher<T> {
public void subscribe(Subscriber<? super T> s);
}
public interface Subscriber<T> {
public void onSubscribe(Subscription s);
public void onNext(T t);
public void onError(Throwable t);
public void onComplete();
}
public interface Subscription {
public void request(long n);
public void cancel();
}
Reactive Streams 는 Maven 에서 다운받을 수 있다.
참고
https://brunch.co.kr/@springboot/153
Project Reactor 3. 리액티브 스트림
3. Reactive Streams Interface | "Project Reactor" 시리즈의 세 번째 글입니다. 하지만, 이 글에서도 "Reactor" 에 대해서는 거의 다루지 않을 예정입니다. 이 글에서는, "Reactive Streams"에 대해서 공부합니다. 급
brunch.co.kr
Reactive Streams
https://engineering.linecorp.com/ko/blog/reactive-streams-with-armeria-1/
Armeria로 Reactive Streams와 놀자! - 1 - LINE ENGINEERING
LINE+에서 오픈소스 Armeria와 Central Dogma를 개발하고 있는 엄익훈입니다. 저는 Reactive Streams의 개념과, Reactive Streams를 오픈 소스 비동기 HTTP/2, RPC, REST 클라이언트/서버 라이브러리인 Armeria에서 사용
engineering.linecorp.com
Reactive Streams API GitHub
https://github.com/reactive-streams/reactive-streams-jvm
GitHub - reactive-streams/reactive-streams-jvm: Reactive Streams Specification for the JVM
Reactive Streams Specification for the JVM. Contribute to reactive-streams/reactive-streams-jvm development by creating an account on GitHub.
github.com
'백엔드 > Spring' 카테고리의 다른 글
[java] BigDecimal error : Non-terminating decimal expansion; no exact representable decimal result. (0) | 2022.05.15 |
---|---|
Connection Factory (0) | 2022.05.13 |
[webflux] PublishOn, SubscribeOn (0) | 2022.04.15 |
Spring WebFlux (0) | 2022.04.14 |
[Intellij] JUnit Test 실행 시 No tests found for given includes (0) | 2022.04.14 |