개발
-
[Spring] JobRegistryBeanPostProcessor (not eligible for auto-proxying) 관련 경고 트러블 슈팅개발 2024. 9. 11. 21:02
배치 어플리케이션이 필요해서 Spring Boot 3.2 버전으로 Spring Batch 프로젝트를 만들었다.그런데 못보던 경고 로그가 떠서, 해당 이슈와 관련하여 문제부터 원인파악, 근본적인 해결까지 정리해 보았다.문제스프링 배치 5.0 이상 버전부터는 기존의 배치 환경을 구성할 때 사용하는 @EnableBatchProcessing 어노테이션을 프로그래밍 방식으로 대체하는 DefaultBatchConfiguration 클래스를 지원하는데, JobRepository등에 필요한 DataSource를 따로 설정하기 위해 DefaultBatchConfiguration 클래스를 상속하여 아래와 같이 구성하였다.package day.mercury.batch;import ...@Configurationpublic ..
-
[Spring Webflux] #4 스프링 웹플럭스의 코틀린 코루틴 지원 내부 구현 뜯어보기개발 2024. 7. 29. 05:23
스프링 진영에서 코틀린은 참 매력적인 언어다. 이미 많은 유명한 서비스들이 코틀린 스프링을 사용하고 있고, 개인적 경험에서는 자바의 장황한 문법에 비해 간결해진 코드와 Null Safety가 정말 큰 장점으로 느껴진다. 특히 웹플럭스에서, 선언형(declarative)으로 메소드 체이닝을 통해 코드를 작성하는 기존의 Reactor와 달리 코틀린 코루틴은 명령형(imperative)으로 Non-blocking 코드를 간단 명료하게 작성할 수 있다. Reactor가 Kotlin Coroutines과 어떻게 호환 되는지, Spring은 코루틴을 어떻게 지원하는지, 그리고 Spring Webflux 어플리케이션에서 코루틴을 어떻게 사용하는지 정리해보았다. 본문을 요약하면,Reactor(Mono/Flux) Co..
-
[Spring Webflux] #3 스프링 웹플럭스에서 AOP 제대로 사용하기개발 2024. 4. 11. 22:07
스프링의 핵심 요소 중 하나인 AOP(관점 지향 프로그래밍)는 횡단 관심사(cross-cutting concerns)를 모듈화 한다. 간단히 말하면 흔히 스프링에서의 선언적 트랜잭션(@Transactional)처럼 여러 서비스/비즈니스 로직에 대해 공통적으로 사용하는 부분을 따로 분리해서 관리한다고 생각하면 될 것 같다. 일반적인 AOP 구현 방법 스프링에서 AOP는 @AspectJ를 사용해 어노테이션 기반으로 작성할 수 있다. 간단한 예시로 함수 실행 시간을 측정하는 로직을 AOP를 이용해 구현해 보겠다. 일단 우리가 흔히 아는 Spring MVC의 경우 아래와 같이 구현 할 수 있다. @Aspect @Component public class ExecutionTimerAspect { private fi..
-
[Spring Webflux] #2 내가 스프링 웹플럭스를 공부한 방법개발 2024. 4. 10. 00:32
작년 9월, 자바의 새로운 LTS 버전인 자바 21가 출시 되면서, 함께 정식 릴리즈 된 가상 스레드가 웹플럭스를 대체할 수 있을 것인지가 주변 개발자들과의 이야기에서 항상 화두에 올랐다. 반년이 지났지만 아직 시기 상조인 것 같다. 스프링의 큰 장점인 거대 자바 생태계가 온전히 가상 스레드를 지원 못하는 탓일까 싶다. 특히 Spring Data JPA가 디폴트로 사용하는 커넥션 풀 라이브러리 HikariCP가 아직 가상 스레드를 지원하지 않는다. (관련 PR: https://github.com/brettwooldridge/HikariCP/pull/2055) 그리고 식품 e커머스로 꽤 인지도 있는 모 회사의 어느 개발팀에서도 가상 스레드 하나보고 자바 21로 전환을 시도했지만, 여러 한계로 다시 롤백했다..
-
Docker로 Elasticsearch + Kibana 개발환경 구성하기개발 2023. 11. 24. 05:19
회사에서 검색 시스템 개발을 맡게 되었고 아파치 루씬 기반의 검색엔진인 Elasticsearch를 사용하기로 하였다. 로컬 개발 환경을 간단하게 구축하기 위해 도커를 활용해 구성하였다. ES, Kibana 컨테이너 실행하기 우선, Elasticsearch와 Kibana가 사용할 도커 네트워크를 만든다. docker network create [NETWORK_NAME] Elasticsearch와 Kibana 컨테이너를 실행한다. 버전은 8.10.4를 사용했다. 필요한 포트들을 포트포워딩 한다. 9200번 포트: Elasticsearch API 9300번 포트: Elasticsearch 클러스터 내 에서 노드간 통신에 사용 5601번 포트: Kibana 대시보드 개발 환경 이므로 "discovery.type..
-
[Spring Webflux] #1 Reactive Streams 이해하기개발 2023. 2. 25. 16:39
Spring Webflux에서 비동기 로직을 지원하기 위해 사용되는 Reactor 라이브러리는 Reactive Stream의 구현체이다. Reactor 라이브러리를 보기에 앞서, Reactive Streams을 공부하려 한다. Reactive Streams? Reactive Streams는 non-blocking backpressure를 이용한 비동기 스트림 처리를 위한 표준을 뜻한다. Backpressure: 시스템의 한 컴포넌트(생성자)가 데이터를 생성하는 속도가 다른 컴포넌트(소비자)가 데이터를 소비하는 속도를 초과할 때 발생하는 압력 Non-blocking backpressure: 컴퓨터 네트워크와 분산 시스템에서 과부하와 혼잡을 방지하기 위한 컴포넌트 간의 데이터 흐름을 제어하는 기술. 소비자 ..
-
[Spring Webflux] #0 Webflux 기본 개념개발 2023. 2. 22. 03:02
스프링에서, 웹 스택은 Web Servlet, Web Reactive 이렇게 두가지가 있다. Spring MVC 와 Spring WebFlux Web Servlet에 해당되는 Spring MVC는 Java EE의 Servlet API를 기반으로 한다. Spring MVC는 Blocking 방식이다. 요청들이 들어오면 큐에 넣고 미리 만들어 둔 스레드 풀에서 스레드를 가져와서 사용한다. (하나의 요청에 하나의 스레드를 사용한다.) 그래서 스레드 풀 사이즈를 초과하는 많은 요청들이 들어오면 나머지 요청들을 처리하지 못하고 이전 작업들이 처리 될 때까지 큐에서 대기하게 되므로 지연시간이 늘어나게 된다. (Thread Pool Hell 현상) 이와 같은 대용량 트래픽 문제를 해결하기 위해 Spring 5버전부터..
-
라즈베리파이 우분투 서버 구축 #2 Docker Engine 설치개발 2022. 12. 6. 18:09
API 서버의 버전 관리를 도커 컨테이너를 사용하여 하기로 결정했다. 설치 방법은 도커 공식 문서를 참고하였다. https://docs.docker.com/engine/install/ubuntu/ Install Docker Engine on Ubuntu docs.docker.com 모든 커맨드는 최상위 경로에서 실행하였다. 1. apt 패키지 리스트를 최신화하고, apt 커맨드가 https를 사용할 수 있도록 허용할 수 있도록 필요한 패키지들을 설치한다. $ sudo apt-get update $ sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release 2. 도커 공식 GPG Key를 추가한다. $ sudo mkdir -p /etc/apt/..