The choice between WebClient.builder() and WebClient.create() depends on the level of customization required for the WebClient instance. WebClient.create():This static factory method provides a quick way to create a WebClient instance with default settings. It can also accept a base URL as an argument, simplifying the creation of clients for a specific endpoint. Use this when minimal configurati..
Reactor(Mono, Flux)와 코루틴... 도대체 무슨 사이인데Mono와 Flux는 Reactor에서 쓰이는 타입이다.Spring webFlux에서 사용하는 것이 Reactor이기 때문에, webFlux에서는 주로 Mono나 Flux를 쓴다. 근데 우리 프로젝트는 코루틴을 쓴단 말이지. (코드에 suspend가 있으면 당신은 코루틴을 쓰고 있는 것이다) 그러면 코루틴은 뭔데.코루틴도 비동기 처리에 쓰인다...그럼 둘의 다른 점은 뭔데... 항목 Kotlin Coroutines Reactor (Mono/Flux) 핵심 개념suspend를 통한 일시 정지비동기 스트림코드 스타일명령형 (imperative)선언형 (declarative)철학동기처럼 보이는 비동기데이터 흐름 기반 처리설계 목표간결..
exchange.request.body.map { dataBuffer -> ... } exchange.request.body의 타입은:Flux즉, DataBuffer들을 비동기적으로 흘려보내는 스트림이다.map { dataBuffer -> ... }에서 dataBuffer는 Flux가 하나씩 방출하는 요소(DataBuffer)다.그럼 왜 dataBuffer가 사용 가능한가?Flux는 코틀린에서 말하면 (List나 Sequence와 비슷하게)T 타입의 값들을 하나씩 처리할 수 있는 구조exchange.request.body가 Flux이므로.map { dataBuffer -> ... }는 그 안의 DataBuffer를 하나씩 꺼내서 처리하겠다는 의미dataBuffer는 DataBuffer 타입 하나의 인스턴..
spring boot 프로젝트의 WebFliter 테스트 코드를 작성하며 공부한 내용을 정리한다.번역은 훗날의 내가 이해할 수 있을 정도의 수준으로 해놨으므로 서치타고 들어온 방문객들은 원문을 읽기를 권장한다. 공식문서Spring Framework : WebFilter https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/server/WebFilter.htmlSpirng Framework : ServerWebExchange https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/server/Serv..
class MDCContext( val contextMap: MutableMap = MDC.getCopyOfContextMap(), key: CoroutineContext.Key) : ThreadContextElement, AbstractCoroutineContextElement(key) {key는 단지 AbstractCoroutineContextElement(key)에 넘겨주기 위한 용도로만 필요하지, 이 클래스 내부에서 사용할 필요가 없기 때문에 val을 붙이지 않은 것이다.