스프링과 백엔드 개발에 아~주 관심이 많은 개발자입니다 ☺
Bài viết
Hỏi & Đáp
[Python 오퍼레이터 기본] 10:30 에 나오는 UnPaused 시 동작 이유가 궁금합니다.
아 AI 가 보여준 링크를 참조하겠습니다. 스케줄링과 관련된 질문입니다. - 인프런 | 커뮤니티 질문&답변제가하려던 질문이랑 똑같네요.
- 0
- 3
- 58
Hỏi & Đáp
StepExecutionListener 의 afterStep 에서 return ExitStatus.FAILED 에 의한 동작에 의문이 갑니다.
자문자답입니다. package coding.toast.batch.job.reader.listener; import org.springframework.batch.core.*; public class EmptyReadFailureListener implements StepExecutionListener { @Override public ExitStatus afterStep(StepExecution stepExecution) { // 기존에 이미 예외가 터져서 failed 된 상태인지 먼저 확인한다. if (!stepExecution.getStatus().equals(BatchStatus.FAILED)) { if (stepExecution.getReadCount() > 0) { return stepExecution.getExitStatus(); } else { // 추후 Job 과 Step 의 재기동을 위해서 BatchStatus.FAILED 를 꼭 설정합니다. // SimpleJob 에서는 이 설정을 하면 남아 있는 Step 들의 실행을 방지한다. stepExecution.setStatus(BatchStatus.FAILED); return ExitStatus.FAILED .addExitDescription("exit Because Of No Item Read"); } } return stepExecution.getExitStatus(); } } 이렇게 하면 결과적으로 다음과 같은 결과가 나옵니다.JobExecution : Batch Status = FAILED / EXIT STATUS = FAILED첫번째 StepExecution : Batch Status = FAILED / EXIT STATUS = FAILED두번째 StepExecution : 실행 자체가 안됩니다.키 포인트는 stepExecution.setStatus(BatchStatus.FAILED); 를 afterStep 메소드 내에서 한번 호출한다는 점입니다. 이렇게 됨으로써 Job, Step 모두 추후에 재실행이 됩니다. 그리고 만약에 SimpleJob 이 아니라 FlowJob 을 구성한다면 아래처럼 할 수도 있습니다.@Configuration @RequiredArgsConstructor public class MyJobConfig { private final JobRepository jobRepository; private final PlatformTransactionManager transactionManager; @Bean public Job customItemStreamConfigJob() { //@formatter:off return new JobBuilder("customItemStreamConfigJob", jobRepository) .start(customItemStreamConfigStep()) .on("FAILED") .fail() .from(customItemStreamConfigStep()) .on("*").to(simpleStep()) .end() .build(); // 조근 더 간단하게는 아래처럼 작성할 수 있습니다. // return new JobBuilder("customItemStreamConfigJob", jobRepository) // .start(customItemStreamConfigStep()) // .on("EMPTY_READ").fail() // .next(simpleStep()).end() // .build(); //@formatter:on } // 나머지 코드는 이전 질문에 작성한 예시코드와 동일합니다. // ...생략... } 참고한 글: java - Spring batch job exit status for failed step - Stack Overflow
- 0
- 2
- 233
Hỏi & Đáp
스프링 배치 5 변경점 정리
spring batch 5.0.0~5.1.x 버전 사용 시 BeanPostProcessor Warning Log 해결법 공유합니다. 문제점(사진)현재 spring boot 3.3.x (spring batch 5.1) 버전 코드를 실행만 해도 위처럼 BeanPostProcessor 관련 Warning Log 가 나옵니다. 큰 문제를 일으키지는 않지만 굉장히 성가십니다.해결법이 로그가 보기 싫으면 2개의 Bean 을 등록하면 됩니다.(spring batch 5.0 ~ 5.1 버전 일 때만 하시면 됩니다, 5.2 에서는 고쳐질 예정입니다.) package coding.toast.springbatch; import org.springframework.batch.core.configuration.JobRegistry; import org.springframework.batch.core.configuration.support.JobRegistrySmartInitializingSingleton; import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @SpringBootApplication public class SpringBatchAppApplication { public static void main(String[] args) { SpringApplication.run(SpringBatchAppApplication.class, args); } // https://github.com/spring-projects/spring-batch/issues/4519 // https://docs.spring.io/spring-batch/reference/5.2-SNAPSHOT/job/advanced-meta-data.html#jobregistrysmartinitializingsingleton @Bean public static BeanDefinitionRegistryPostProcessor jobRegistryBeanPostProcessorRemover() { return registry -> registry.removeBeanDefinition("jobRegistryBeanPostProcessor"); } @Bean public JobRegistrySmartInitializingSingleton jobRegistrySmartInitializingSingleton(JobRegistry jobRegistry) { return new JobRegistrySmartInitializingSingleton(jobRegistry); } }- BeanDefinitionRegistryPostProcessor : 문제가 되는 JobRegistryBeanPostProcessor 제거- JobRegistrySmartInitializingSingleton : JobRegistryBeanPostProcessor 을 대체함 참고참고로 이 문제는 Spring batch 5.2 (=> Spring Boot 3.4.x 적용 예정) 에서 고쳐질 예정입니다.Multiple trationDelegate$BeanPostProcessorChecker Warnings Arise When Using Spring Boot 3.2.0 · Issue #4519 · spring-projects/spring-batch · GitHub What’s new in Spring Batch 5.2 :: Spring Batch ps.2024-11-22현재 시간(2024-11-22)부로 Spring Boot 3.4 가 나왔고,내부적으로 사용하는 Spring Batch 의 버전도 5.2 올라갔습니다.테스트해본 결과 위에서 말한 복잡한 설정을 안해도 이제는 WARNING 로그가 뜨지 않습니다!(사진)
- 14
- 3
- 1.8K
Hỏi & Đáp
jobLauncherTestUtils 빨간 줄 질문입니다.
(사진) 위 그림처럼 2개의 플러그인을 설치하시면 됩니다.Jakarta EE: Batch ApplicationSpring Batch참고: 빨간줄 나와도 잘됩니다. 저는 그냥 찝찝해서 설치해서 빨간줄 안 나오게 했습니다.
- 0
- 2
- 1.4K
Hỏi & Đáp
Xstream 관련 ForbiddenClassException 또는 CannotResolveClassException 해결방법
감사합니다~
- 2
- 2
- 571
Hỏi & Đáp
윈도우 사용자 질문
안녕하세요, 지나가던 Window 10 사용자입니다.개인적으로 Window 사용하시면 아래 2개를 설치하시는 것을 강력 추천합니다.(WSL2 기반) Docker DesktopWSL2 기반의 리눅스 (Ubuntu 추천)이러면 비록 호스트 환경(Window 환경) 에서 Docker Desktop 을 설치해도 WSL2 환경의 우분투에서도 docker 명령어가 똑같이 먹히도록 자동으로 설정됩니다.이러면 Linux 환경에서 Docker 를 활용하다보니, 미묘하게 mac 과 window 다른 점들을 전혀 신경쓰지 않아도 됩니다.
- 2
- 2
- 391
Hỏi & Đáp
현재 제가 겪고 있는 상황인데 조언 부탁드립니다.
저도 예전에 비슷한 상황을 마주친 적이 있어서 질문을 올렸고,스스로 답을 찾은 적이 있습니다. 해당 질문 링크를 공유합니다.https://www.inflearn.com/questions/567543 추가적으로 이런 일정 시간 대기 또는 비동기 동작에 대한 Junit 테스트를 하고 싶다면GitHub - awaitility/awaitility: Awaitility is a small Java DSL for synchronizing asynchronous operations을 알아보시면 좋을 거 같습니다.
- 0
- 2
- 505
Hỏi & Đáp
notifyAll 이 더 선호되는 이유에 대한 조금 더 detail 한 설명 요청드립니다.
선생님 답변과 더불어서 보면 좋은 StackOverflow 글이 있어서 공유합니다.Java: notify() vs. notifyAll() all over againhttps://stackoverflow.com/a/3186336선생님이 답변 주신대로 하나의 WaitSet 에 서로 다른 이유로 wait 상태에 놓인 쓰레드가 모두 담아질 때 문제가 생기는데요,이러한 문제가 정확히 어떻게 발생할 수 있는지에 대한 자세한 예시를 이 글에서 보여줍니다.ps. 해당 글을 읽을 때는 [Monitor - 모니터 - 1] 강의 27 분 즈음에 나오는 그림이 머리에 그려두고 읽으면 더 도움이 됩니다.
- 1
- 3
- 1K
Hỏi & Đáp
9003 포트 터미널로 실행하는 방법 공유드립니다.
이 방법 외에도 mvn spring-boot:run `-Dspring-boot.run.jvmArguments='-Dserver.port=9003'처럼 - 앞에 백틱(`) 을 붙이는 방법도 있습니다!
- 3
- 2
- 981
Hỏi & Đáp
모달이 부드럽게 뜨지 않습니다.
저도 같은 현상이 있었는데, 간단하게 transition 태그에 "appear" 속성을 추가하니 해결되었습니다. 참고링크: https://stackoverflow.com/questions/61190142/the-transition-of-my-vue-modal-component-in-my-twig-file-is-not-working
- 1
- 3
- 504