본문 바로가기

spring async

Spring mvc async rest api /* 결제 내역 조회시 해당 결제 내역에 사용자 정보를 포함해야 한다. 사용자 정보 조회를 위해 결제아이디로 사용자 정보를 조회 후 결제 정보에 조인 시켜야 한다. 해당 프로세스를 비동기적으로 처리 하도록 한다. */ Enable Async and config thread pool @EnableAsync @Configuration public class BeanConfig { /** * @see https://kapentaz.github.io/spring/Spring-ThreadPoolTaskExecutor-%EC%84%A4%EC%A0%95/# */ @Bean("accounting-async-thread") public Executor asyncThread(){ ThreadPoolTaskExecutor .. 더보기
Spring mvc async rest api /* 결제 내역 조회시 해당 결제 내역에 사용자 정보를 포함해야 한다. 사용자 정보 조회를 위해 결제아이디로 사용자 정보를 조회 후 결제 정보에 조인 시켜야 한다. 해당 프로세스를 비동기적으로 처리 하도록 한다. */ Enable Async and config thread pool @EnableAsync @Configuration public class BeanConfig { /** * @see https://kapentaz.github.io/spring/Spring-ThreadPoolTaskExecutor-%EC%84%A4%EC%A0%95/# */ @Bean("accounting-async-thread") public Executor asyncThread(){ ThreadPoolTaskExecutor .. 더보기
spring controller async request process with executor 스프링에서 컨트롤러에서 요청에 대한 처리를 동기가 아닌 비동기 처리하는 방식을 제공 하고있다. 스프링5 의 webflux 사용한다면 해당 비동기 처리를 사용할 수 있지만 스프링 5 버전 이하의 시스템에서는 해당 처리가 필요할 것이다. 스프링이 제공하는 방식 비동기로 처리하기 위해 스프링에서 여러가지 반환 유형을 제공한다. 요청에 대해 즉각 응답을 주는것이 아닌 요청에 대한 처리를 백그라운드로 처리하여 완료시 사용자에게 반환 함으로써 요청 처리에 대한 병목을 없애도록 한다. 스프링이 제공하는 비동기 응답 > 다른 스레드로 생성된 비동기 결과 > > DefferedResult > > ListenableFuture > > CompletionStage > > CompletableFuture > > 연산 후 생성.. 더보기
Spring 비동기 사용 방법(Async in Spring boot) 프로퍼티 설정 my.task.core.poolsize=10my.task.capacity=50my.task.max.poolsize=20my.scheduler.poolsize=20 설정 클래스 @Configuration@EnableAsyncpublic class MyBean{ @Bean @ConfitureationProperties(prefix="my.task") public Executor taskExecutor() { ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); /* 코드상에 명시적으로 설정 하려면 아래 주석 처리 부분을 사용 */ //taskExecutor.setCorePoolSize(10); //taskExecutor.set.. 더보기