-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YEL-214 [setting] YEL-214 [fix] 스프링 배치이슈
- Loading branch information
1 parent
4b94592
commit a127d97
Showing
5 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/java/com/yello/server/infrastructure/batch/ChunkProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package com.yello.server.infrastructure.batch; | ||
|
||
|
||
import com.yello.server.domain.user.entity.User; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.batch.item.ItemProcessor; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@RequiredArgsConstructor | ||
@Configuration | ||
public class ChunkProcessor { | ||
public ItemProcessor<User, User> lunchEventProcessor() { | ||
ItemProcessor<User, User> item = user -> { | ||
System.out.println(user.getId() + ", "+ user.getName() + " dds121212"); | ||
return user; | ||
}; | ||
return item; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
src/main/java/com/yello/server/infrastructure/batch/StepConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
package com.yello.server.infrastructure.batch; | ||
|
||
import com.yello.server.domain.user.entity.User; | ||
import com.yello.server.domain.user.entity.UserData; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.Step; | ||
import org.springframework.batch.core.job.builder.JobBuilder; | ||
import org.springframework.batch.core.repository.JobRepository; | ||
import org.springframework.batch.core.step.builder.StepBuilder; | ||
import org.springframework.batch.repeat.RepeatStatus; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Configuration | ||
public class StepConfiguration { | ||
|
||
private final ChunkReader chunkReader; | ||
private final ChunkProcessor chunkProcessor; | ||
private final ChunkWriter chunkWriter; | ||
|
||
@Bean | ||
public Step lunchEventAlarmStep(JobRepository jobRepository, PlatformTransactionManager transactionManager) throws Exception { | ||
public Step lunchEventAlarmStep(JobRepository jobRepository, | ||
PlatformTransactionManager transactionManager) throws Exception { | ||
return new StepBuilder("lunchEventStep", jobRepository) | ||
.<User, User>chunk(100, transactionManager) | ||
.reader(chunkReader.userDataJdbcPagingItemReader()) | ||
.writer(chunkWriter.lunchEventWriter()) | ||
.build(); | ||
.<User, User>chunk(10, transactionManager) | ||
.reader(chunkReader.userDataJdbcPagingItemReader()) | ||
.processor(chunkProcessor.lunchEventProcessor()) | ||
.writer(chunkWriter.lunchEventWriter()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters