Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

feat : 배치 포인트 만료 (1) #61

wants to merge 3 commits into from

Conversation

KATEKEITH
Copy link
Collaborator

작업 내용

  • Spring Batch meta data table을 생성한다. #59
  • 포인트 만료 1일전 Valid인 데이터 중 유효기간이 2일 남은 데이터의 status를 Invalid로 Update
  • 포인트 만료 1일전 Valid인 데이터 중 유효기간이 2일 남은 데이터를 Kafka MQ에 Push

@KATEKEITH KATEKEITH self-assigned this Aug 1, 2023
@KATEKEITH KATEKEITH changed the title 만료 예정인 포인트 데이터를 메시지큐에 넣는다. feat : 배치 포인트 만료 프로세스 Aug 1, 2023
@KATEKEITH KATEKEITH changed the title feat : 배치 포인트 만료 프로세스 feat : 배치 포인트 만료 Aug 1, 2023
@KATEKEITH KATEKEITH changed the title feat : 배치 포인트 만료 feat : 배치 포인트 만료 (1) Aug 1, 2023
job:
enabled: true
datasource:
url: jdbc:mysql://localhost:3306/good_choice
Copy link
Collaborator

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 {
Copy link
Collaborator

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)
Copy link
Collaborator

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'");
Copy link
Collaborator

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);
Copy link
Collaborator

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() {
Copy link
Collaborator

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)
Copy link
Collaborator

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>() {
Copy link
Collaborator

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

배치역활을 수행하는 클래스 네이밍을 내포해 주시면 더 좋을것 같네요

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요고 트리거는 어떻게 하실 생각이신가요?

Copy link
Collaborator

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해피 케이스만 있네요
중요한건 실패 됬을때 데이터를 어떻게 처리 되는지에 대한 케이스도 필요합니다.

테스트 코드는 코드에 변경사항을 감지하기도 하지만 또 다른 기능도 있는데 뭐가 있을까요?

Copy link
Collaborator

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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

배치 업무는 배치 실행 시간, 종료, 성공 여부, 미수행에 대한 모니터링 등 신경을 많이 써줘야 합니다.

1 시작과 완료 로그는 어디에 어떻게 쌓는게 좋을까요?
2 배치가 미수행 됬을 때 대비하여 어떻게 모니터링 하는게 좋을까요?
3 배치가 중간에 실패 됬을때 이전에 성공한 건들은 어떻게 하는게 좋을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants