Skip to content

Conversation

@jihukimme
Copy link
Member

@jihukimme jihukimme commented Aug 31, 2025

:메모: 작업 내용

  • 의존성 추가 (Dependencies Added)
    • Spring Batch 기능 사용을 위해 spring-boot-starter-batch 의존성을 추가
    • 데이터베이스 연동을 위해 mybatis-spring-boot-starter 의존성을 추가
  • 계층적 워크플로우 도입
    • 단일 Job 개념을 확장하여, 여러 Job의 실행 순서를 정의하는 최상위 WORKFLOW 개념을 도입
    • JOB과 TASK의 관계를 N:M(다대다)으로 변경하여, TASK의 재사용성을 극대화 (JOB_TASK 매핑 테이블 추가)
    • Spring Boot Batch는 전체 흐름을 제어하는 Orchestrator로, 크롤링/LangChain 등 실제 작업은 FastAPI Worker가 수행하도록 역할을 분리
  • 동적 스케줄링 구현
    • @scheduled 어노테이션을 사용한 정적 스케줄링을 제거
    • TaskScheduler를 사용하여 SCHEDULE 테이블에 정의된 정보를 런타임에 동적으로 등록/제거/수정하는 DynamicSchedulerService를 구현
  • 핵심 설정 활성화 (Core Configurations Enabled)
    • 메인 애플리케이션에 @EnableBatchProcessing, @EnableScheduling 어노테이션을 추가하여 Spring Batch와 스케줄링 기능을 활성화
    • 향후 동적 스케줄링 구현에 사용될 TaskScheduler Bean을 SchedulerConfig에 미리 정의
  • Workflow, Job, Task, Schedule 등의 초기 데이터 객체(DTO)와 MyBatis 매퍼 인터페이스 추후 작성 예정
  • DynamicSchedulerService의 상세 구현과 각 Tasklet의 개발은 후속 PR에서 진행될 예정

:링크: 관련 이슈

  • Closes #이슈번호
  • Related to #이슈번호

:말풍선: 추가 요청사항

:흰색_확인_표시: 체크리스트

코드 품질

  • 커밋 컨벤션 준수 (feat/fix/docs/refactor 등)
  • 불필요한 코드/주석 제거

테스트

  • 로컬 환경에서 동작 확인 완료
  • 기존 기능에 영향 없음 확인

배포 준비

  • 환경변수 추가/변경사항 문서화
  • DB 마이그레이션 필요 여부 확인
  • 배포 시 주의사항 없음

- ProductCrawlingData: 배치 작업의 Reader -> Processor -> Writer 단계 사이에서 데이터를 실어 나를 내부용 데이터 상자
- FastApiCrawlingResponse: RestTemplate이 FastAPI 서버에 크롤링을 요청한 후, 그 응답(JSON)을 담아올 외부용 데이터 상자
- ProductCrawlingData라는 상자에 DB 데이터를 담거나, 상자의 내용물로 DB를 업데이트할 수 있도록 실제 SQL 쿼리를 CrawlingMapper.xml에 작성하고, 이를 Java에서 호출할 수 있도록 CrawlingMapper.java 인터페이스로 연결
@jihukimme jihukimme requested a review from Copilot August 31, 2025 08:17
@jihukimme jihukimme self-assigned this Aug 31, 2025
@jihukimme jihukimme added the enhancement New feature or request label Aug 31, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a batch processing system for product crawling using Spring Batch. The feature enables scheduled crawling of product information from external APIs to update product data (price and stock status) in the database.

Key changes:

  • Adds Spring Batch infrastructure for product crawling with parallel processing and fault tolerance
  • Implements a scheduled task that runs daily at 8 AM to trigger the batch job
  • Creates DTOs and MyBatis mappers for product data handling

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
build.gradle Adds Spring Batch starter dependency
UserServiceApplication.java Enables scheduling support
CrawlingBatchConfig.java Configures batch job with reader, processor, writer and fault tolerance
CrawlingScheduler.java Implements scheduled task to trigger crawling job
CrawlingMapper.java Defines MyBatis mapper interface for database operations
CrawlingMapper.xml Contains SQL queries for reading and updating product data
ProductCrawlingData.java DTO for product data transfer
FastApiCrawlingResponse.java DTO for external API response

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 11 to 12
id
LIMIT #{_pagesize} OFFSET #{_skiprows}
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

The parameter names '_pagesize' and '_skiprows' use underscore-prefixed naming which is inconsistent with MyBatis conventions. These should be changed to 'pageSize' and 'skipRows' or the mapper method should use @param annotations to properly map these parameters.

Suggested change
id
LIMIT #{_pagesize} OFFSET #{_skiprows}
LIMIT #{pageSize} OFFSET #{skipRows}

Copilot uses AI. Check for mistakes.
log.info("Requesting crawl for product: {}", product.getName());

// FastAPI URL을 코드에 직접 작성 (추후 외부 설정으로 분리 권장)
String fastApiUrl = "http://your-fastapi-server.com/crawl?url=" + product.getUrlToCrawl();
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

The FastAPI URL is hardcoded and uses a placeholder hostname. This should be externalized to application properties for different environments and proper configuration management.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

하드 코딩 되어있는 Fast API의 URL은 추후에 수정할 예정

log.info("Requesting crawl for product: {}", product.getName());

// FastAPI URL을 코드에 직접 작성 (추후 외부 설정으로 분리 권장)
String fastApiUrl = "http://your-fastapi-server.com/crawl?url=" + product.getUrlToCrawl();
Copy link

Copilot AI Aug 31, 2025

Choose a reason for hiding this comment

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

URL concatenation without proper encoding could lead to URL injection vulnerabilities. Use UriComponentsBuilder or similar to safely construct URLs with parameters.

Copilot uses AI. Check for mistakes.
@can019
Copy link
Collaborator

can019 commented Sep 1, 2025

@jihukimme
일단 fallback을 다루기 쉬운게 batch긴하지만 지금 상황으론 shedule만 잡아도 될 것 같아요

데이터 양이 많으면 batch, 아님 cron으로 처리하죠. 기획부분에서 먼저 잡고 가면 좋을 것 같습니다. 회의가 필요할 것 같습니다

실행 로직 관리(재처리, 상태관리)가 필요하기 때문에 batch가 좋을 것 같아요

@jihukimme jihukimme changed the title Feature/product crawling batch 동적 워크플로우 기반 배치 시스템 초기 설정 Sep 5, 2025
@jihukimme jihukimme removed the enhancement New feature or request label Sep 5, 2025
@jihukimme jihukimme marked this pull request as ready for review September 5, 2025 08:22
@can019
Copy link
Collaborator

can019 commented Sep 7, 2025

@jihukimme 완료되면 self assignee 붙이시고 머지해주시면 됩니다

@jihukimme
Copy link
Member Author

@jihukimme 완료되면 self assignee 붙이시고 머지해주시면 됩니다

확인했습니다..!

@jihukimme jihukimme merged commit e72d71d into develop Sep 7, 2025
4 checks passed
@jihukimme jihukimme deleted the feature/product-crawling-batch branch September 7, 2025 07:17
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.

3 participants