fix: Register async executor as a bean using @Bean #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix: Graceful Shutdown 버그 수정 위한 AsyncExecutor Bean 등록
안녕하세요! 해당 템플릿 기반으로 프로젝트를 진행하다가 비동기 동작에서 Graceful Shutdown이 제대로 동작하지 않는 문제를 발견하여, 버그를 수정하여 PR 요청 드립니다.
최초 발견
Spring Batch App을 구성하고 배치 수행 결과를 Slack으로 발송하는 로직을 비동기로 구현하였는데, 배치가 종료된 이후 Slack 메시지가 발송되지 않고 App이 종료되는 문제를 확인하였습니다.
검증
이 문제를 제대로 확인하기 위해 아래와 같은 테스트를 진행하였습니다.
해당 테스트는 프로젝트의 PR의 수정 사항에 추가하지는 않고, 따로 진행하였습니다.
(필요하시다면 해당 테스트 코드는 테스트 커밋 링크에서 직접 확인하실 수 있습니다.)
수정
기존 ThreadPoolTaskExecutor가 Bean으로 등록되어 있지 않아 스프링 컨텍스트 종료 시 Graceful Shutdown이 제대로 동작하지 않은 것으로 보고, ThreadPoolTaskExecutor를 Bean으로 관리하도록 설정하였습니다.

또한 Bean으로 등록됨에 따라 initialize가 불필요해지게 되어 해당 부분 삭제하였습니다.
(이에 대한 내용은
@EnableAsync의 주석에서도 확인할 수 있었습니다.)검증
동일한 테스트 코드 실행 결과 성공하는 것을 확인하였습니다.

참고 사항
잘못된 내용이나 보완해야 할 내용이 있다면 편하게 말씀 부탁드립니다.
감사합니다.