다음 모노를 제공하십시오 :
Mono<Void> mono1 = Mono.fromRunnable(() -> {
System.out.println("sleep1");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
System.out.println("mono1");
});
Mono<Void> mono2 = Mono.fromRunnable(() -> {
System.out.println("mono2");
});
Mono<Void> mono3 = Mono.fromRunnable(() -> {
System.out.println("mono3");
});
둘 다 :
mono1
.then(mono2)
.then(mono3)
.block();
그리고 :
mono1
.and(mono2)
.and(mono3)
.block();
같은 결과를 얻습니다 :
sleep
mono1
mono2
mono3
Mono#then
및
Mono#and
이 경우
에서 https://projectreactor.io/docs/ core/release/reference/index.html # which-operator :
[If you] have a sequence but [you are] not interested in values and [you] want to switch to another Mono at the end, [use]
Mono#then(mono)
.[당신이 1 개의 모노와 모든 소스에서 모노로의 종료를 조정하여 출판사를 합치려면, [사용]
Mono#and
.
이것은
#and
가있는 사례를 찾는 데 도움이되지 않습니다
그리고
#then
불행히도 다르게 행동 할 것입니다.
-
답변 # 1
관련 자료
- python - var = fun ()과 var = fun의 차이점
- 어셈블리 언어에서 문자열과 배열의 차이점
- excel - myDate와 Int (myDate)의 차이점은 무엇입니까
- azure active directory - "시스템 할당"ID와 앱 등록 "서비스 사용자"의 차이점
- JavaScript에서 변경 가능한 데이터와 변경 불가능한 데이터의 차이점은 무엇입니까?
- Jenkins의 '차단됨', '고착 됨', '보류 중', '구축 가능'작업의 차이점
- reactjs - React에서 then과 async/await의 차이점
- python - refindall ()과 strcount ( 'str')의 차이점은 무엇입니까?
- multithreading - Java에서 Atomic set () 및 getAndSet () 메소드의 차이점
- drools - Statefull 세션과 Stateless 세션의 차이점
- python - 두 사전 간의 최소 차이 계산
- 파이썬에서 목록과 JSON 출력의 차이점을 얻으십시오
- matplotlib - mplpyplotfigure와 mplfigure의 차이점
- powerbi - Import와 Connect의 차이점은 SQL Server 분석 서비스를 사용하는 것입니다
- c++ - 새 요소에 대한 포인터와 새 배열의 차이점은 무엇입니까?
- database - 눈송이와 록셋의 업데이트 차이점은 무엇입니까? 일괄 업데이트가 발생합니까?
- c - 포인터를 사용하여 값을 지정하는 것과 차이점은 무엇입니까?
- github - git hooks와 Azure DevOps 파이프 라인의 차이점은 무엇입니까?
- google bigquery - (여러) 두 개의 다른 행의 차이점을 얻는 방법?
Mono#and
단지 "현재 모노 및 다른 소스로부터의 리턴 신호를 리턴 된 보이드 모노에 결합시킨다". 항상Mono<Void>
를 반환합니다. 오직 두 개의Mono
의 종료를 조정할 수 있습니다 s.Mono#then
당신이 두Mono
를 체인 할 수 있습니다 함께하고 최종 결과는Mono
에 의해 결정됩니다 매개 변수로 전달되었습니다. 이런 의미에서,Mono#then
Mono#flatMap
의 더 원시적 인 버전입니다 유일한 차이점은Mono#flatMap
의 내부입니다. 당신은 이전Mono
의 결과에 액세스 할 수 있습니다 다른Mono
로 변환 할 수있는 체인 인스턴스.Mono#then
Mono#and
와 함께 작업이 순차적으로 실행됩니다. 주문에 대한 보장은 없습니다 (적어도 문서에서).