webflux

    [WebFlux] Reactive Streams

    Reactive Streams is an initiative to provide a standard for asynchronous stream processing with non-blocking back pressure. Reactive Streams는 논블로킹 백프레셔를 이용해 비동기 스트림 처리를 위한 표준을 제공한다. (리액티브 프로그래밍에 대한 인터페이스만을 제공) Reactive Streams 인터페이스 Reactive Streams의 주요 인터페이스는 다음과 같다. 1) Publisher 데이터를 생성하고, Subscriber에게 데이터를 발행한다. subscribe subscribe메서드에 인자로 Subcriber를 전달하여 등록한다. Publisher는 Subscriber에게 순차적으로 데..

    [TIL - 20230621] Webflux R2DBC 후원 동시성 문제 해결

    💻문제점1다음과 같이 points 테이블이 있다.포인트 사용을 테스트해보면 test1의 포인트는 100점 줄어들고, 스트리머인 test3의 포인트는 100점 증가한다. @Test @DisplayName("포인트 사용 테스트") public void testUsePoint() { PointUseDto pointUseDto = new PointUseDto("test3", 100, "message"); StepVerifier.create( pointService.usePoint(createMember("test1"), pointUseDto) ).assertNext(responseEntity -> { Asser..

    [TIL - 20230606] Webflux + Websocket 전체 채팅

    💻문제점 흠... webflux에서 kafka랑 rsocket 으로 채팅하는 예제를 찾으며 시도, 실패를 계속 반복하다가 webflux에서 websocket과 kafka를 적용하는 것까지 와버렸다. 다른 사람 레퍼런스를 봐도 이해가 안 가는 부분이 많아서... 일단 빈 프로젝트에 kafka producer, consumer를 만들어 테스트하고, websocket 연결도 따로 테스트해서 합쳐보자..!라고 생각했다. 내가 직접 안 해본 것이니 이해가 안되는 거라는 생각이 들어서... 그렇게 kafka 테스트를 따로 끝내고, websocket 전체 채팅을 우선 만들었다. 테스트를 하려고 websocket test client 크롬 확장 프로그램을 열어 url에 ws://localhost:8080/ws-chat..

    [Spring] Webflux + RSocket, React 사용한 전체 채팅 구현

    Webflux에서 RSocket을 사용하여 전체 채팅을 구현해보자. build.gradle 의존성은 다음과 같이 추가했다. dependencies { implementation 'org.springframework.boot:spring-boot-starter-rsocket' implementation 'org.springframework.boot:spring-boot-starter-webflux' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org...

    [Spring] Spring WebFlux 간단한 예제

    Spring WebFlux를 이용하여 간단하게 상품 등록/삭제, 카트에 상품 담기/삭제 기능을 구현해보도록 하겠다. 1. 프로젝트 생성 2. 환경 구성 build.bradle 에 다음 dependency를 추가해준다. implementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:3.3.0' implementation 'org.mongodb:mongodb-driver-sync' testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:3.3.0' 프로젝트 구조는 다음과 같다. 3. 코드 Cart.java @Getter @Setter @ToString @NoArgsConstructor @AllArg..