spring-batch

Spring Batch - AmqpWriter and AmqpReader example

痴心易碎 提交于 2021-02-07 10:21:48
问题 Need a solution to write a data on RabbitMQ using AmqpWriter and read the data using RabbitMQ using AmqpReader . We're not looking for Apache Kafka, we want to simply send say Program details and consume it. Writer Code JobConfig.java @Configuration public class JobConfig { @Autowired private StepBuilderFactory stepBuilderFactory; @Autowired private JobBuilderFactory jobBuilderFactory; @Bean public ConnectionFactory connectionFactory() { return new CachingConnectionFactory("localhost"); }

Spring Batch - AmqpWriter and AmqpReader example

妖精的绣舞 提交于 2021-02-07 10:20:31
问题 Need a solution to write a data on RabbitMQ using AmqpWriter and read the data using RabbitMQ using AmqpReader . We're not looking for Apache Kafka, we want to simply send say Program details and consume it. Writer Code JobConfig.java @Configuration public class JobConfig { @Autowired private StepBuilderFactory stepBuilderFactory; @Autowired private JobBuilderFactory jobBuilderFactory; @Bean public ConnectionFactory connectionFactory() { return new CachingConnectionFactory("localhost"); }

Cannot catch exception in spring batch's ItemWriter

谁说胖子不能爱 提交于 2021-02-07 09:32:46
问题 I'm writing a Spring Batch process to migrate a dataset from one system into another. In this case this is as simple as using a RowMapper implementation to build the object from a query before handing off to the ItemWriter . The ItemWriter calls the save method on my DAO (defined as an interface and handled by spring data) The issue is this: I have a unique constraint on the MyItem table, and therefore saving a duplicated record will result in a DataIntegrityViolationException . I have tried

How to access read raw data in a spring batch job (xml or csv)

淺唱寂寞╮ 提交于 2021-02-05 12:29:55
问题 I have different import jobs to get data into our system. Since the data is coming from different producers, i sometimes have csv data, or different formats of xml. Each of these import types has its own spring batch job with its own configuration (different readers, different processors but all the same writer). My task now is, that i also need the "raw data" in my system and not only the converted objects. So for a csv import i want to have access to the raw line that builds up one entity.

Retry not working when Spring Batch managed transaction rolls back

给你一囗甜甜゛ 提交于 2021-02-05 09:55:07
问题 In one of the steps of my Spring Batch job, I'm trying to configure it so that when ObjectOptimisticLockingFailureException happens, the step can be retried and hopefully the retry will work. @Bean public Step myStep(StaxEventItemReader<Response> staxEventResponseReader, ItemWriter<Response> itemWriter, ItemProcessor<? super Response, ? extends Response> responseProcessor) { return stepBuilderFactory.get("myStep") .<Response, Response>chunk(1) .reader(staxEventResponseReader) .processor

Spring batch: get ExecutionContext in the listener

非 Y 不嫁゛ 提交于 2021-02-05 09:45:23
问题 I am new to Spring batch. I need to count the element read, written and that have gone in error. I've defined a step like this: /*...*/ @Bean public Step stepMain(StepBuilderFactory stepBuilderFactory) { return stepBuilderFactory.get("stepMain").<T, T> chunk(this.chuckSize).reader(reader(null, null)).processor(new Processor()).writer(writer()).faultTolerant().skipPolicy(new AlwaysSkipItemSkipPolicy()).listener(new ListenerReader()).listener(new ListenerProcessor()).listener(new ListenerWriter

Spring batch: get ExecutionContext in the listener

流过昼夜 提交于 2021-02-05 09:44:25
问题 I am new to Spring batch. I need to count the element read, written and that have gone in error. I've defined a step like this: /*...*/ @Bean public Step stepMain(StepBuilderFactory stepBuilderFactory) { return stepBuilderFactory.get("stepMain").<T, T> chunk(this.chuckSize).reader(reader(null, null)).processor(new Processor()).writer(writer()).faultTolerant().skipPolicy(new AlwaysSkipItemSkipPolicy()).listener(new ListenerReader()).listener(new ListenerProcessor()).listener(new ListenerWriter

Spring Batch: how to restart and rerun only skipped items

故事扮演 提交于 2021-02-05 07:10:03
问题 Can I restart job and process only skipped items after I have corrected the mistakes in file? I'm reading documentation and not finding currently this possibility. You can restart job if it is failed, but I'm thinking restarting job after it has been completed with some skipped items. If this cannot be achieved with configuration, what would be good way to implement it myself? 回答1: What I have done in a case similiar to yours, is to log each skipped item in a file. Then I created a second job

Issue retrieving a ExecutionContext from a SkipListener

一笑奈何 提交于 2021-02-05 07:09:29
问题 I am trying to retrieve a spring batch ExecutionContext from a SkipListener . Here is what I have attempted (I rely on annotations instead of interfaces in order to implement my listeners): import com.xxxx.domain.UserAccount; import lombok.extern.slf4j.Slf4j; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.annotation.BeforeStep; import org.springframework.batch.core.annotation.OnSkipInWrite; import org.springframework.mail.MailSendException; import

Spring Batch: how to restart and rerun only skipped items

╄→尐↘猪︶ㄣ 提交于 2021-02-05 07:05:27
问题 Can I restart job and process only skipped items after I have corrected the mistakes in file? I'm reading documentation and not finding currently this possibility. You can restart job if it is failed, but I'm thinking restarting job after it has been completed with some skipped items. If this cannot be achieved with configuration, what would be good way to implement it myself? 回答1: What I have done in a case similiar to yours, is to log each skipped item in a file. Then I created a second job