spring-batch

Pass JobParameters and ExecutionContext to @Bean Tasklet?

余生颓废 提交于 2019-12-03 21:58:39
I am converting Spring Batch XML based application into the Spring Boot annotations. In my XML file, I am not sure how to pass those jobParameters and execution context to tasklet ? <beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util" xsi

spring amqp rabbitmq MessageListener not working

自古美人都是妖i 提交于 2019-12-03 21:25:18
I am trying to use rabbitmq using spring amqp, below is my configuration. <rabbit:connection-factory id="rabbitConnectionFactory" port="${rabbitmq.port}" host="${rabbitmq.host}" /> <rabbit:admin connection-factory="rabbitConnectionFactory" /> <rabbit:queue name="${rabbitmq.import.queue}" /> <rabbit:template id="importAmqpTemplate" connection-factory="rabbitConnectionFactory" queue="${rabbitmq.import.queue}" /> <beans:bean id="importExchangeMessageListener" class="com.stockopedia.batch.foundation.ImportMessageListener" /> <rabbit:listener-container connection-factory="rabbitConnectionFactory"

Spring Batch @StepScope cannot generate CGLIB subclass

老子叫甜甜 提交于 2019-12-03 21:18:20
EDIT I created a test project that replicates the issue. It can be found at https://github.com/tomverelst/test-batch . First run the maven command exec:java to start a HSQL database. Then you can run the JUnit test MigrationJobConfigurationTest to load the Spring application context. Original question When starting my Spring Batch application, I get the following exception when Spring is loading my job's configuration: Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.sun.proxy.$Proxy34]: Common causes of this problem include

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

半城伤御伤魂 提交于 2019-12-03 20:41:38
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. 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, and in JobExecutions, you can get StepExecutions. All these give you the status of the job and individual

Skippable exception classes for Spring Batch with java based configuration

别说谁变了你拦得住时间么 提交于 2019-12-03 17:50:21
问题 I configure a step in XML like this: <batch:step id="slaveStep"> <batch:tasklet> <batch:chunk reader="reader" processor="processor" writer="writer" commit-interval="10" skip-limit="100000"> <batch:skippable-exception-classes> <batch:include class="MyException"/> </batch:skippable-exception-classes> </batch:chunk> </batch:tasklet> </batch:step> In the java configuration I use a StepBuilder like this: @Bean public StepBuilder stepBuilder(String stepName) { return new StepBuilder(stepName); }

How does one open a Reader when implementing ItemReader in a Spring Batch project?

倖福魔咒の 提交于 2019-12-03 16:47:28
In a Spring Batch project I need to compose a record out of multiple lines. I'm implementing ItemReader to accumulate multiple lines before returning an object. After working through several example projects I have pieced this together but I am faced with a ReaderNotOpenException . I have triple checked the path to the file is correct. When I debug the delegate contains the resource and file path from my configuration file. Any help appreciated. Config file: <bean id="cvsFileItemReader" class="com.mkyong.XYZFileRecordReader"> <property name="delegate"> <bean class="org.springframework.batch

Spring batch: Retry job if does not complete in particular time

穿精又带淫゛_ 提交于 2019-12-03 16:26:53
I am working on a Spring batch application where I have used RetryTemplate with SimpleRetryPolicy . In this application, ItemProcessor usually takes 30-35 mins to complete a particular task. But sometimes, it takes from than 2hrs to complete that same task. Is there a way to retry my ItemProcessor , if the assigned task is not completed within given time period? I am looking for some Java/Spring in-build functionality instead of writing my own timeout logic. You can define transactional-attributes to a given step. ( https://docs.spring.io/spring-batch/trunk/reference/htmlsingle/

Spring Batch (java-config) executing step after a jobExeuctionDecider

非 Y 不嫁゛ 提交于 2019-12-03 16:12:35
I'm trying to configure a Flow in spring batch using java-config, this flow basically has to do this: Execute a init step(which adds a record in the database), then execute a decider to check file existence, 2.1. IF the files exists it will execute the load job (which is another flow with a bunch of steps in parallel) Execute a finish step (which adds a record in the database), this should always run, even if 2.1 was not executed. I tried to do this configuration, but the finish step never runs: Flow flow = new FlowBuilder<SimpleFlow>("commonFlow") .start(stepBuilderFactory.get("initStep")

What is the best way to test job flow in Spring-Batch?

谁说胖子不能爱 提交于 2019-12-03 15:53:11
I've got a complicated batch application, and I want to test that my assumptions about flow are correct. Here's a much simplified version of what I'm working with: <beans> <batch:job id="job1"> <batch:step id="step1" next="step2"> <batch:tasklet ref="someTask1"/> </batch:step> <batch:step id="step2.master"> <batch:partition partitioner="step2Partitioner" step="step2" /> <batch:next on="*" to="step3" /> <batch:next on="FAILED" to="step4" /> </batch:step> <batch:step id="step3" next="step3"> <batch:tasklet ref="someTask1"/> </batch:step> <batch:step id="step4" next="step4"> <batch:tasklet ref=

how to send a custom object as Job Parameter in Spring Batch?

限于喜欢 提交于 2019-12-03 15:49:57
I have a requirement of sending a Custom Object to the Spring Batch Job , where this Object is used continuously used by the Item Processor for the business requirement. How can we send custom object from outside to the Job Context. This Object changes from Job to Job and generated at runtime depending on Business case. How can send this as a Job Parameter? or is there any way that i can set this Object to the respective Job ? can overriding Spring JobParameter help me in any way? or are there any Big issues as an outcome of this Overriding behaviour ? Thrax This question has been asked on the