-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : 배치 포인트 만료 (1) #61
base: develop
Are you sure you want to change the base?
Conversation
job: | ||
enabled: true | ||
datasource: | ||
url: jdbc:mysql://localhost:3306/good_choice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
live 인데 local이 맞나요?
@RunWith(SpringRunner.class) | ||
@SpringBatchTest | ||
@SpringBootTest(classes = { ExpiredPoint.class, TestBatchConfig.class }) | ||
public class ExpiredPointTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@Repository | ||
public interface PointRepository extends JpaRepository<Point, Long> { | ||
|
||
@Query(value = "select * from point where status = 'VALID'", nativeQuery = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네이티브 쿼리를 쓰신 이유가 있을까요?
} | ||
}; | ||
|
||
reader.setQueryString("SELECT p FROM Point p where p.status = 'VALID'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 여기서 위험요소가 있다면 어떤걸까요?
}; | ||
|
||
reader.setQueryString("SELECT p FROM Point p where p.status = 'VALID'"); | ||
reader.setPageSize(chunkSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chunkSize는 보통 파라미터로 빼서 flexible 하게 만들어 주시는게 좋습니다.
|
||
@Bean | ||
@StepScope | ||
public JpaItemWriter<Point> expiredPointWriter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금은 프로젝트라 상관없겠지만
보통 배치 업무는 대량의 데이터를 핸들링 하는 도메인 이다 보니까
성능 고려를 안 할 수 없는데요
이 부분을 좀 더 개선해 볼 수 있다면 뭐가 있을까요?
@Slf4j | ||
@RequiredArgsConstructor | ||
@Configuration | ||
// @ConditionalOnProperty(name = "job.name", havingValue = JOB_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
불필요한 주석은 제거 해주시는게 좋습니다.
이것도 습관이에요~
@Bean | ||
@StepScope | ||
public JpaPagingItemReader<Point> expiredPointReader() { | ||
JpaPagingItemReader<Point> reader = new JpaPagingItemReader<Point>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
말씀 드렸지만 paging 방식은 데이터가 많아지면 (대충 10만개 넘어가면?) 속도가 느려지는데요,
개선 할 방법이 뭐가 있을지 고민하면 좋을것 같습니다.
@RequiredArgsConstructor | ||
@Configuration | ||
// @ConditionalOnProperty(name = "job.name", havingValue = JOB_NAME) | ||
public class ExpiredPoint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
배치역활을 수행하는 클래스 네이밍을 내포해 주시면 더 좋을것 같네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요고 트리거는 어떻게 하실 생각이신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
배치 업무는 배치 실행 시간, 종료, 성공 여부, 미수행에 대한 모니터링 등 신경을 많이 써줘야 합니다.
1 시작과 완료 로그는 어디에 어떻게 쌓는게 좋을까요?
2 배치가 미수행 됬을 때 대비하여 어떻게 모니터링 하는게 좋을까요?
3 배치가 중간에 실패 됬을때 이전에 성공한 건들은 어떻게 하는게 좋을까요?
private PointRepository pointRepository; | ||
|
||
@Test | ||
public void 포인트의_상태가_변경된다() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해피 케이스만 있네요
중요한건 실패 됬을때 데이터를 어떻게 처리 되는지에 대한 케이스도 필요합니다.
테스트 코드는 코드에 변경사항을 감지하기도 하지만 또 다른 기능도 있는데 뭐가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RequiredArgsConstructor | ||
@Configuration | ||
// @ConditionalOnProperty(name = "job.name", havingValue = JOB_NAME) | ||
public class ExpiredPoint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
배치 업무는 배치 실행 시간, 종료, 성공 여부, 미수행에 대한 모니터링 등 신경을 많이 써줘야 합니다.
1 시작과 완료 로그는 어디에 어떻게 쌓는게 좋을까요?
2 배치가 미수행 됬을 때 대비하여 어떻게 모니터링 하는게 좋을까요?
3 배치가 중간에 실패 됬을때 이전에 성공한 건들은 어떻게 하는게 좋을까요?
작업 내용