본문 바로가기

Spring|Spring-boot/Spring Batch16

Spring Batch Parameter 배치를 실행에 필요한 값을 parameter를 통해 외부에서 주입 JobParameters는 외부에서 주입된 parameter를 관리하는 객체 parameter를 JobParameters와 Spring EL로 접근 (두 가지 사용 가능) - String parameter = jobParameters.getString(key, defaultValue); - @Value("#{jobParameters [key]}") 우선 jobParameters를 사용해보자. tasklet을 사용할 때이다. private Tasklet tasklet(){ List items = getItems(); return (contribution, chunkContext) -> { StepExecution stepExecution =.. 2021. 2. 28.
Spring Batch Architecture www.tutorialspoint.com/spring_batch/spring_batch_architecture.htm Spring Batch - Architecture - Tutorialspoint Spring Batch - Architecture Following is the diagrammatic representation of the architecture of Spring Batch. As depicted in the figure, the architecture contains three main components namely, Application, Batch Core, and Batch Infrastructure. Application www.tutorialspoint.com 스프링 배치 아.. 2021. 2. 27.
Spring Batch step 작성해보기 job에서 여러 가지 step을 만들기 연습이다. @Bean public Step shareStep(){ return stepBuilderFactory.get("shareStep") .tasklet((contribution, chunkContext) ->{ StepExecution stepExecution = contribution.getStepExecution(); ExecutionContext stepExecutionContext = stepExecution.getExecutionContext(); stepExecutionContext.putString("stepKey", "step execution context"); JobExecution jobExecution = stepExecution.get.. 2021. 2. 27.
Spring Batch Job Repository Job Repository는 스프링 배치에 대한 메타 데이터를 저장합니다. 그 구조는 spring-batch-core에 존재합니다. mysql을 사용하므로 mysql.sql을 복사해 생성해보겠습니다. 다음과 같이 여러 테이블이 생성되었습니다. 테이블마다 역할은 다음과 같습니다. BATCH_JOB_INSTACE - job이 실행되며 생성되는 최상위 계층의 테이블입니다 - job_name과 job_key를 기준으로 하나의 row가 생성되며, 같은 name, key는 저장될 수 없습니다. - job_key는 BATCH_JOB_EXECUTION_PARAMS에 저장되는 Parameter를 나열해 암호화해 저장합니다. - JobInstace클래스와 매핑 됩니다. BATCH_JOB_EXECTION - job이 실행되.. 2021. 2. 27.
Batch Hello World 스프링 부트를 사용해 실습을 진행할 것이다. 의존성은 다음과 같다. dependencies { implementation 'org.springframework.boot:spring-boot-starter-batch' implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' runtimeOnly 'mysql:mysql-connector-java' annotationProcessor 'o.. 2021. 2. 27.
Spring Batch Batch가 뭘까? 큰 단위의 작업을 일괄 처리할 수 있다는 것입니다. 일괄 처리한다는 것은 컴퓨터의 자원을 최대로 사용해서 무거운 작업을 일괄처리할 수 있다는 것을 의미합니다. 보통 비실시간성 처리에 사용하게 됩니다. 배치는 컴퓨터 자원이 많이 남는 시간 혹은 다른 배치를 위한 컴퓨터 자원을 사용하는데, 대용량 데이터 계산, 정산, 통계, 데이터베이스, 변환 등에 사용되게 됩니다. 사용자와 상호 작용으로 주거니 받거니 하는 것보단 스케줄러와 같은 시스템에 의해 할당받아 실행되는 대상입니다. - crontab, jenkins .... 이러한 배치 처리를 하기 위한 Spring Framework 기반으로 만든 Batch처리 기술을 Spring Batch라고 합니다. spring의 여러 특징을 모두 포함하고.. 2021. 2. 27.