spring-batch

Can we use @Autowired in a Tasklet in Spring Batch?

不问归期 提交于 2019-12-21 21:48:30
问题 I have a Spring Batch tasklet as follows in my application. @Service public class SampleTasklet implements Tasklet { @Autowired private UserService userService; @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.err.println(userService.getUsers().size()); return RepeatStatus.FINISHED; } } and I have a Service Class as follows. @Service @Slf4j public class UserService { public Map<String, String> getUsers(){ return null } }

Spring Batch Admin (2.0.0.M1): error creating bean batchMBeanExporter

此生再无相见时 提交于 2019-12-21 20:14:34
问题 I am trying to run spring batch admin from spring boot application. I am using this excellent example from Michael (@mminella). This application works fine. However, I need similar application using maven; I went ahead and created one with same files, jobs, configs and dependencies. But I ended up in following exception. Only difference I see is the version of spring-batch-core. With maven it's version is 3.0.6 while with gradle (Michael's application) has 3.0.4. Not sure what's going on when

Spring Batch Item Reader - use skippedLinesCallback to set input field names

夙愿已清 提交于 2019-12-21 19:53:29
问题 I have a simple job as below: <batch:step id="step"> <batch:tasklet> <batch:chunk reader="itemReader" processor="itemProcessor" writer="itemWriter" commit-interval="5000" /> </batch:tasklet> </batch:step> itemReader is as below: <bean id="itemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step"> <property name="linesToSkip" value="1"></property> <property name="skippedLinesCallback" ref="skippedLinesCallback" ></property> <property name="lineMapper"> <bean class

Spring Batch Job Running in Infinite loop

感情迁移 提交于 2019-12-21 16:24:48
问题 I am working on simple Spring Batch Job. When I launch job its running in infinite loop. It doesn't stop. According to my scheduler time it should run after every 10 seconds. But when job starts it doesn't stop. Its just keeps printing sysouts from reader, processor and writer respectively. I am creating job with reader, processor and writer. And I am doing all configuration by annotations. Not by xml. Here is Batch Configuration @Configuration @EnableBatchProcessing @EnableScheduling public

Spring Batch Job Running in Infinite loop

无人久伴 提交于 2019-12-21 16:21:05
问题 I am working on simple Spring Batch Job. When I launch job its running in infinite loop. It doesn't stop. According to my scheduler time it should run after every 10 seconds. But when job starts it doesn't stop. Its just keeps printing sysouts from reader, processor and writer respectively. I am creating job with reader, processor and writer. And I am doing all configuration by annotations. Not by xml. Here is Batch Configuration @Configuration @EnableBatchProcessing @EnableScheduling public

Spring Batch:How to monitor currently running jobs & show progress on jsp page

南笙酒味 提交于 2019-12-21 06:16:11
问题 I want to know how to monitor status of my currently running batch jobs.My jobs are basically processing folder with some default steps so I want to show progress to the user step by step .I am using Tasklets and DB Job Repository .Explaining with some example code for achieving this will be more helpful. Thank you. 回答1: If you want to develop your own monitor app/webpage, you may want to look into the JobExplorer or JobOperator interface. It provides you with methods to get the JobExecutions

Connecting to both spring-batch and application database using spring-boot

隐身守侯 提交于 2019-12-21 06:01:18
问题 Spring batch had it's own database schema. My application has it's own database schema. I want to keep these separated into different databases so the spring-batch tables are not inside my applications database. By default spring-boot only supports connection to a single database. How do I configure it so that all spring-batch related operations go into the spring-batch database and all my own code goes into my applications database? I am using the latest spring-boot 1.2.2. 回答1: Well this is

Spring Batch, JdbcExecutionContextDao java.util.Map$Entry deserializer issue, xstream 1.4.1

别说谁变了你拦得住时间么 提交于 2019-12-21 05:09:21
问题 I have a problem using Spring Batch 2.1.9: when i use jobExplorer.getJobExecution(jobExecutionId) , i find a problem when DAO has to deserialize a string like: {"map":[{"entry":{"string":"parsedComparingDate","date":"2014-03-08 23:00:00.0 UTC"}}]} from the BATCH_JOB_EXECUTION_CONTEXT table, using method JdbcJobExecutionDao.getJobExecution() . I know that spring batch uses xstream 1.3, but in my Pom, i have: spring-batch 2.1.9 ; xstream 1.4.1 (inherited from smooks); jettison 1.3.3 (inherited

Spring RESTful web services - High volume data processing

大憨熊 提交于 2019-12-21 02:56:08
问题 I'm trying to build a Spring/Spring Boot- RESTful web service, Which accepts a CSV file with 1 million rows/40 columns in each row as input (From a Angular based front end) and will be a synchronous call. User have to be notified on the upload status before proceeding to other screens. So, wait time can't be more than few mins(say 5 mins). Each of these rows has to be validated against what is in DB and if found to be valid, same will be inserted into DB. In short, each row can be a separate

Using 2 different datasources : Spring batch

孤者浪人 提交于 2019-12-21 01:59:08
问题 I have 2 different datasources , one to read and another one to write results like below: ItemReader should get data from dataSource_1. ItemWriter should write data to dataSource_2. knowing that reader and writer are in the same tasklet. As per the documentation, we can configure a single transaction manager at tasklet In this scenario, how do i use the transaction manager here? I cannot rely on the container and i'm not using ORM layer (JPA..), i use direct JDBC driver to read in database 1