Announcement Announcement Module
Collapse
No announcement yet.
jobOperator.getRunningExecutions Hangs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jobOperator.getRunningExecutions Hangs

    I am testing the output of batch processes in spring enabled (AbstractJUnit4SpringContextTests) test cases. However, they do not complete because the call to jobOperator.getRunningExecutions does not always return, and as a result the process hangs.

    Can anyone think of a reason why this would happen?

    Using spring 3.0.5, spring batch 2.1.8 on jdk1.6

    My spring batch beans are configured below.

    Code:
    	<job-repository id="jobRepository" data-source="dataSource"
    		transaction-manager="txnManager" isolation-level-for-create="READ_COMMITTED"
    		table-prefix="JOB_" max-varchar-length="1000" />
    
    	<beans:bean id="jobLauncher" 
    		class="org.springframework.batch.core.launch.support.SimpleJobLauncher"
    		p:jobRepository-ref="jobRepository" />
    
    	<beans:bean id="jobRegistry" 
    		class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
    
    	<beans:bean id="jobExplorer" 
    		class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"
    		p:dataSource-ref="dataSource" p:tablePrefix="JOB_" />
    
    	<beans:bean id="jobOperator" scope="prototype"
    		class="org.springframework.batch.core.launch.support.SimpleJobOperator"
    		p:jobLauncher-ref="jobLauncher" p:jobExplorer-ref="jobExplorer"
    		p:jobRepository-ref="jobRepository" p:jobRegistry-ref="jobRegistry" />
    
    	<job id="exampleJob">
    		<step id="exampleJobStep">
    			<tasklet transaction-manager="txnManager">
    				<chunk reader="exampleReader" writer="exampleWriter"
    					commit-interval="100" />
    			</tasklet>
    		</step>
    	</job>

    the relevant bean invoked by the test case that kicks off a batch process performs the following (in pseudo code)
    Code:
    	@Autowired
    	@Qualifier("jobLauncher")
    	private JobLauncher synchLauncher;
    
    	@Autowired
    	private JobOperator jobOperator;
    
    	public void execute(String jobName) {
    		if (jobOperator.getRunningExecutions(jobName).size() == 0) { // hangs here
    			JobExecution result = jobLauncher.run(
    				(Job) applicationContext.getBean(jobName),
    				new JobParametersBuilder());
    		}
    	}
    Last edited by rjh-sgc; Apr 4th, 2012, 03:42 PM.

  • #2
    ok I think I found the problem:

    my datasource uses c3p0 connection pooling, with the following setting:
    c3p0.max_size=5

    increase this number, and more test cases will complete.

    So the question now why is each job is pulling a db connection and not releasing it upon completion...

    Comment

    Working...
    X