Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: First time using Spring Batch. Problems to run it.

  1. #1
    Join Date
    Apr 2008
    Posts
    8

    Question [SOLVED] First time using Spring Batch. Problems to run it.

    Hello,

    I am trying to run a really simple spring-batch job.
    Here is it's invocation class:

    Code:
    import org.springframework.batch.core.Job;
    import org.springframework.batch.core.JobParameters;
    import org.springframework.batch.core.launch.JobLauncher;
    import org.springframework.beans.factory.BeanFactory;
    import org.springframework.beans.factory.xml.XmlBeanFactory;
    import org.springframework.core.io.ClassPathResource;
    import org.springframework.core.io.Resource;
    
    
    public class SimpleSpringBatchTest {
    
    	public static void main(String[] args) {
    		Resource res = new ClassPathResource("simplespringbatchtest.xml"); 
    		BeanFactory fac = new XmlBeanFactory(res);
    		JobLauncher launcher = (JobLauncher)fac.getBean("launcher");
    		Job job = (Job)fac.getBean("job");
    		JobParameters params = (JobParameters)fac.getBean("params");
    		try {
    			launcher.run(job, params);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    	
    }
    Here is its context xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans (xmlns part...)>
    	
    	<bean id="job" class="org.springframework.batch.core.job.SimpleJob">
    		<property name="steps">
    			<list>
    				<bean id="step1" class="org.springframework.batch.core.step.tasklet.TaskletStep">
    					<property name="tasklet" ref="step1tasklet" />
    					<property name="jobRepository" ref="repository" />
    				</bean>
    			</list>
    		</property>
    	</bean>
    	
    	<bean id="launcher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    		<property name="jobRepository" ref="repository" />
    	</bean>
    	
    	<bean id="repository" class="org.springframework.batch.core.repository.support.SimpleJobRepository">
    		<constructor-arg ref="mapJobInstanceDao" />
    	    <constructor-arg ref="mapJobExecutionDao" />
    	    <constructor-arg ref="mapStepExecutionDao" />
    	</bean>
    
    	<bean id="mapJobInstanceDao" class="org.springframework.batch.core.repository.dao.MapJobInstanceDao" />
    	<bean id="mapJobExecutionDao" class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />
        <bean id="mapStepExecutionDao" class="org.springframework.batch.core.repository.dao.MapStepExecutionDao" />
    
    	<bean id="params" class="org.springframework.batch.core.JobParameters" />
    	
    	<bean id="step1tasklet" class="Step1Tasklet">
    		<property name="msg">
    			<value>Rodando step1</value>
    		</property>
    	</bean>
    	
    	
    </beans>
    Here is the other relevant class, the Step1Tasklet:
    Code:
    import org.springframework.batch.core.step.tasklet.Tasklet;
    import org.springframework.batch.repeat.ExitStatus;
    
    
    public class Step1Tasklet implements Tasklet {
    
    	private String msg;
    	
    	public ExitStatus execute() throws Exception {
    		System.out.println(msg);
    		return ExitStatus.FINISHED;
    	}
    
    	public String getMsg() {
    		return msg;
    	}
    
    	public void setMsg(String msg) {
    		this.msg = msg;
    	}
    
    }
    When I try to run it, I get the following exception:
    Code:
    2008-06-09 13:50:57,031 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Loading XML bean definitions from class path resource [simplespringbatchtest.xml]>
    2008-06-09 13:50:57,824 INFO [org.springframework.batch.core.launch.support.SimpleJobLauncher] - <No TaskExecutor has been set, defaulting to synchronous executor.>
    2008-06-09 13:50:57,925 INFO [org.springframework.batch.core.launch.support.SimpleJobLauncher] - <Job: [SimpleJob: [name=job]] launched with the following parameters: [{}{}{}{}]>
    2008-06-09 13:50:57,928 INFO [org.springframework.batch.core.launch.support.SimpleJobLauncher] - <Job: [SimpleJob: [name=job]] failed with the following parameters: [{}{}{}{}]>
    java.lang.NullPointerException
    	at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:162)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81)
    	at SimpleSpringBatchTest.main(SimpleSpringBatchTest.java:20)
    java.lang.NullPointerException
    	at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:162)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81)
    	at SimpleSpringBatchTest.main(SimpleSpringBatchTest.java:20)
    Can anyone help me discover what is wrong? What I am not passing to spring-batch that I should?
    Last edited by zayhen; Jun 9th, 2008 at 04:31 PM. Reason: Problem solved!

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    You didn't set the JobRepository property on the job. I'm surprised that there isn't a more obvious exception, but the problem is pretty clear.

  3. #3
    Join Date
    Apr 2008
    Posts
    8

    Default

    Quote Originally Posted by Dave Syer View Post
    You didn't set the JobRepository property on the job. I'm surprised that there isn't a more obvious exception, but the problem is pretty clear.
    Thank you so much! It worked nicely!
    As I said, this is the first time I try to run Spring Batch. :-)

  4. #4

    Red face plz give me the working code

    hi sorry for asking this question.. i am new two spring batch and i am searching for a sample code .. i read this post and i am working on the same example.. can u plz tell me how to set job repository for an job.. i thing u have set a property for job repository in ur configuration file .. i dont know where to set it.. plz give ur working code .. sorry if its a silly question..

  5. #5
    Join Date
    Apr 2008
    Posts
    8

    Default

    Quote Originally Posted by shafik_success View Post
    hi sorry for asking this question.. i am new two spring batch and i am searching for a sample code .. i read this post and i am working on the same example.. can u plz tell me how to set job repository for an job.. i thing u have set a property for job repository in ur configuration file .. i dont know where to set it.. plz give ur working code .. sorry if its a silly question..
    The configuration is exactly the same. Just include
    Code:
    		<property name="jobRepository" ref="repository" />
    after in your job configuration as a property.

  6. #6

    Smile Thanks

    hi thanks a lot .. i got the output .. good sample to start spring batch...

  7. #7
    Join Date
    Apr 2008
    Posts
    8

    Default

    Quote Originally Posted by shafik_success View Post
    hi thanks a lot .. i got the output .. good sample to start spring batch...
    I am really pleased it was useful for somebody besides me.

  8. #8

    Default spring batch

    Hi,

    I'm beginner with spring quartz and i have a problem for my project.

    I'would whan my job is failed or sleep, the scheduler relance it and the job can retake
    where it has stopped.

    This is a differents steps how i was did :
    In the first i have m y class scheduler:
    Code:
    @DisallowConcurrentExecution
    public class JobLauncherDetails extends QuartzJobBean /*implements JobExecutionListener*/ {
    
    	private static final String JOB_DATA_MAP_MAX_RETRY = "maxRetry";
    	//private static final String JOB_DATA_MAP_NB_RETRIES = "nbRetries";
    	private final static String JOB_LOCATOR_CONTEXT_KEY = "jobLocator";
    	private final static String JOB_LAUNCHER_CONTEXT_KEY = "jobLauncher";
    	private static final String JOB_DATA_MAP_START_DATE = "startDate";
    	private static final String JOB_PARAM_LISTENER_DELAY_KEY = "listenerDelay";
    	private static final long JOB_PARAM_DEFAULT_LISTENER_DELAY = 1000;
    
    	private static Logger log = LoggerFactory.getLogger(JobLauncherDetails.class);
    
    	/**
    	 * Special key in job data map for the name of a job to run.
    	 */
    	private static final String JOB_NAME = "jobName";
    
    	private JobLocator jobLocator;
    	private JobLauncher jobLauncher;
    	private String jobName;
        private JobListener MyjobListener;
    	/**
    	 * Method called by Quartz trigger. The given {@link JobExecutionContext}
    	 * gives info on the Job to run.
    	 */
    	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    		try {
    			jobLocator = (JobLocator) context.getScheduler().getContext().get(JOB_LOCATOR_CONTEXT_KEY);
    			jobLauncher = (JobLauncher) context.getScheduler().getContext().get(JOB_LAUNCHER_CONTEXT_KEY);
    			MyjobListener=(JobListener)context.getScheduler().getContext().get(MyjobListener);
    			
    		
    		} catch (SchedulerException se) {
    			log.error("Unable to get jobLocator and jobLauncher from scheduler context.", se);
    		}
    
    		if (jobLocator == null || jobLauncher == null) {
    			log.error("Unable to run a job without valids jobLocator and jobLauncher.");
    		} else {
    			JobDetail jobDetail = context.getJobDetail();
    			Map<String, Object> jobDataMap = context.getMergedJobDataMap();
    			
    			if (jobDataMap == null || jobDataMap.size() == 0) {
    				log.error("Unable to run a job without a valid jobDataMap (no job name provided...).");
    			} else {
    				
    				jobName = (String) jobDataMap.get(JOB_NAME);
    
    				if (jobName == null || jobName.isEmpty()) {
    					log.error("Unable to run a job: no job name provided...");
    				} else {
    					
    					if(context.getRefireCount()==0) {
    						// Add a date to the jobDataMap so that the job is unique.
    						// It is useful to distinguish 2 instances of the same trigger.
    						// Otherwise, a JobExecutionAlreadyRunningException will be launched
    						// (no need to modify this parameter for a refired job)
    						jobDataMap.put(JOB_DATA_MAP_START_DATE, new Date());
    					}
    
    					JobParameters jobParameters = getJobParametersFromJobMap(jobDataMap);
    					Scheduler sched= context.getScheduler();
    					try {
    						sched.getListenerManager().addJobListener(new NcaJobListener());
    						
    					} catch (SchedulerException e) {
    						// TODO Auto-generated catch block
    						e.printStackTrace();
    					}	
    					
    					if (log.isInfoEnabled())
    						log.info("\n**********************************************************************\n" 
    								+ "* Quartz trigger - start job: {}. Key: {}\n"
    								+ "* Firing unique ID: {}\n" 
    								+ "* Refire count: {}\n" 
    								+ "* Job parameters: {}\n"
    								+ "* isConcurrentExectionDisallowed: {}\n"
    								+ "**********************************************************************\n",
    								new Object[] { jobName, jobDetail==null?"":jobDetail.getKey(), context.getFireInstanceId(), 
    												context.getRefireCount(), jobParameters==null?"":jobParameters.toString(), 
    												context.getJobDetail().isConcurrentExectionDisallowed() });
    					
    					JobExecution jobExec = null;
    					BatchStatus jobStatus = BatchStatus.UNKNOWN;
    
    					try {
    						jobExec = jobLauncher.run(jobLocator.getJob(jobName), jobParameters);
    						log.info("Job Id: {}", jobExec.getId());
    
    					}
    
    					} catch (Exception ex) {
    						if(!(ex instanceof JobExecutionException)) {
    							log.error("Error while running Job [{}]. Rescheduling if possible.\nError: {}\n******************************", jobName, ex.toString());
    							// TODO: retirer ce log...
    							log.error("Error full stack:", ex);
    							
    						} else {
    							throw (JobExecutionException) ex;
    						}
    					}
    
    					if (log.isInfoEnabled())
    						log.info("\n**********************************************************************\n" 
    								+ "* Quartz trigger - end job: {}\n"
    								+ "* Firing unique ID: {}\n" 
    								+ "* Refire count: {}\n" 
    								+ "* Job parameters: {}\n"
    								+ "* Start date: {}\n"
    								+ "* End date: {}\n"
    								+ "* Status: {}\n"
    								+ "**********************************************************************\n",
    								new Object[] { jobName, context.getFireInstanceId(), context.getRefireCount(), 
    												jobParameters==null?"":jobParameters.toString(),
    												jobExec==null?"":jobExec.getStartTime(),
    												jobExec==null?"":jobExec.getEndTime(),
    												jobStatus });
    				}
    			}
    		}
    	}
    
    	/**
    	 * Copy parameters that are of the correct type over to
    	 * {@link JobParameters}, ignoring jobName.
    	 * 
    	 * @return a {@link JobParameters} instance
    	 */
    	private JobParameters getJobParametersFromJobMap(Map<String, Object> jobDataMap) {
    
    		JobParametersBuilder builder = new JobParametersBuilder();
    
    		for (Entry<String, Object> entry : jobDataMap.entrySet()) {
    			String key = entry.getKey();
    			Object value = entry.getValue();
    			if (value instanceof String && !key.equals(JOB_NAME)) {
    				builder.addString(key, (String) value);
    			} else if (value instanceof Float || value instanceof Double) {
    				builder.addDouble(key, ((Number) value).doubleValue());
    			} else if (value instanceof Integer || value instanceof Long) {
    				builder.addLong(key, ((Number) value).longValue());
    			} else if (value instanceof Date) {
    				builder.addDate(key, (Date) value);
    			} else {
    				log.debug("JobDataMap contains values which are not job parameters (ignoring).");
    			}
    		}
    
    		return builder.toJobParameters();
    	}
    
    	/*@Override
    	public void afterJob(JobExecution jobExecution) {
    		// TODO Auto-generated method stub
    		log.info("*************************** Job ended with status: {} ********************", jobExecution.getExitStatus());
    
    		if (ExitStatus.FAILED.equals(jobExecution.getExitStatus())) {
    			log.error("******************************\nJob [{}] failed. Reschedule if possible.\n******************************", jobName);
    
    			// rescheduleJob(jobExecution);
    		}
    	}
    
    	@Override
    	public void beforeJob(JobExecution jobExecution) {
    		log.info("************** Before running job {} **************", jobName);
    	}*/
    }

  9. #9

    Default

    In the second i have a class jobfaileur:

    Code:
    public class JobFailureListener implements JobExecutionListener {
    	private static Logger log = LoggerFactory.getLogger(JobFailureListener.class);
    	private static final String JOB_DATA_MAP_MAX_RETRY = "maxRetry";
    	private static final String JOB_NAME = "jobName";
    	private String jobName;
    	public void beforeJob(JobExecution jobExecution) {
    	// nothing to do
    		log.info("*************************** Job ended with status: {} ********************", jobExecution.getExitStatus());
    	}
    
    	public void afterJob(JobExecution jobExecution, JobExecutionContext context) throws JobExecutionException {
    	
    		if( jobExecution.getStatus() == BatchStatus.COMPLETED ){
    			System.out.println("!!!!!!!!!!!!!!!!!  sa	 marche !!!!!!!!!!!!!!!!");
    	    }
    		
    		else
    		
    			if (!jobExecution.getAllFailureExceptions().isEmpty()) {
    	ExitStatus exitStatus = ExitStatus.FAILED;
    	log.error("******************************\nJob [{}] failed. Reschedule if possible.\n******************************");
    	
    	//rescheduler if possible
    	rescheduleJob(jobExecution, context);
    	
    	for (Throwable e : jobExecution.getAllFailureExceptions()) {
    
    	exitStatus = exitStatus.addExitDescription(e);
    
    	}
    
    	jobExecution.setExitStatus(exitStatus);
    
    	}
    
    	}
    
    	private void rescheduleJob(JobExecution jobExec, JobExecutionContext context) throws JobExecutionException {
    		rescheduleJob(jobExec, context, null);
    	}
    
    	private void rescheduleJob(JobExecution jobExec, JobExecutionContext context, Throwable excep) throws JobExecutionException {
    		// TODO: Gérer la politique de réessai, ex :
    		// http://stackoverflow.com/questions/4408858/quartz-retry-when-failure
    	
    		if(jobExec == null)
    			throw new IllegalArgumentException("jobExec cannot be null.");
    		
    		if(context == null)
    			throw new IllegalArgumentException("context cannot be null.");
    		
    		String fireInstanceId =   context.getFireInstanceId();
    		int refireCount = context.getRefireCount();
    		
    		if (log.isInfoEnabled())
    			log.info("\n**********************************************************************\n" 
    					+ "* Quartz trigger - rescheduling job: {}\n"
    					+ "* Firing unique ID: {}\n" 
    					+ "* Refire count: {}\n" 
    					+ "**********************************************************************\n",
    					new Object[] { jobName, fireInstanceId, refireCount});
    		
    		JobDataMap dataMap = context.getJobDetail().getJobDataMap();
    		int maxRetry = dataMap.getIntValue(JOB_DATA_MAP_MAX_RETRY);
    		
    		JobExecutionException jobExecutionException = null;
    		
            if(maxRetry>0 && refireCount<maxRetry) {        	
            	jobExecutionException = new JobExecutionException("Error: the job [" + jobName + "] didn't end properly, refire it immediately.", excep);
            	jobExecutionException.setRefireImmediately(true);
            	//boolean refireImmediatelyResult = jobExecutionException.refireImmediately();
            	
            	log.info("************** Job Id: {} - rescheduled. ", jobExec.getId());
            	
            	throw jobExecutionException;
            } else {
            	//jobExecutionException = new JobExecutionException("Error: the job [" + jobName + "] didn't end properly. No more retry possible, sending alarm.", excep);
            	
            	log.error("\n**********************************************************************\n" 
    					+ "* Quartz trigger - No more retry possible for job: {}\n"
    					+ "* Firing unique ID: {}\n" 
    					+ "* UNSCHEDULING TRIGGER + SENDING EXPLOIT ALARM...\n"
    					+ "**********************************************************************\n",
    					jobName, fireInstanceId);
            	
            	AlarmDef alarmDef = AlarmExploit.searchBatchFailedAlarmDefByBatchName(jobName);
            	AlarmExploit.generateAlarmWithoutTemplate(alarmDef, "Batch failed", "The following batch failed (no more retry possible): " + jobName, Locale.ENGLISH.toString(), null);
            }
    	}
    
    	@Override
    	public void afterJob(JobExecution jobExecution) {
    		// TODO Auto-generated method stub
    			}
    	
    }
    I also add an sleep for my job and when i run i have a message who said that my job is finished or it's nnot there but juste sleep.
    Please can i have a response, exemple or others suggestions , i need some one to help me please

    Thanks a lot

  10. #10

    Default

    Also this is my xml file:

    <?xml version="1.0" encoding="UTF-8"?>

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ng-context.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">


    <!-- Import NCA Batch applicationContext: mandatory to be able to run jobs usin jobLauncher. -->
    <import resource="applicationContext.xml" />

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="${DBConnectionFactory.default.driver}" />
    <property name="url" value="${DBConnectionFactory.default.url}" />
    <property name="username" value="${DBConnectionFactory.default.user}" />
    <property name="password" value="${DBConnectionFactory.default.password}" />
    </bean>

    <bean id="jobRepository"
    class="org.springframework.batch.core.repository.s upport.MapJobRepositoryFactoryBean">
    <property name="transactionManager" ref="transactionManager" />
    </bean>

    <bean id="transactionManager"
    class="org.springframework.batch.support.transacti on.ResourcelessTransactionManager">
    </bean>

    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>file:${app.home}/cfg/nca.properties</value>
    <value>file:${app.home}/cfg/${module.name}/${module.name}.properties
    </value>
    </list>
    </property>
    </bean>

    <bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
    <property name="showSql" value="${hibernate.show_sql}" />
    </bean>
    </property>
    <property name="jpaPropertyMap">
    <map>
    <entry key="hibernate.cache.use_second_level_cache" value="${hibernate.cache.use_second_level_cache}" />
    <entry key="hibernate.cache.use_query_cache" value="${hibernate.cache.use_query_cache}" />
    <entry key="hibernate.cache.provider_class" value="${hibernate.cache.provider_class}" />
    <entry key="hibernate.dialect" value="${hibernate.dialect}" />
    <entry key="hibernate.show_sql" value="${hibernate.show_sql}" />
    <entry key="hibernate.connection.show_sql" value="true" />
    <entry key="hibernate.id.new_generator_mappings" value="false" />
    </map>
    </property>
    </bean>


    <bean id="jobRegistry"
    class="org.springframework.batch.core.configuratio n.support.MapJobRegistry" />

    <!-- bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTa skExecutor" /--> <!-- Or ThreadPoolTaskExecutor... -->
    <!-- <bean id="taskExecutor" class="org.springframework.core.task.SyncTaskExecu tor" /> -->
    <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.C oncurrentTaskExecutor" />

    <bean id="jobLauncher" class="com.prosodie.nca.batch.launch.JpaIteratorJo bLauncher">
    <property name="jobRepository" ref="jobRepository" />
    <property name="entityManagerFactory" ref="entityManagerFactory" />
    <property name="taskExecutor" ref="taskExecutor" />
    </bean>

    <bean
    class="org.springframework.batch.core.configuratio n.support.JobRegistryBeanPostProcessor">
    <property name="jobRegistry" ref="jobRegistry" />
    </bean>

    <bean id="mapJobRepository"
    class="org.springframework.batch.core.repository.s upport.MapJobRepositoryFactoryBean"
    lazy-init="true" autowire-candidate="false" />


    <!-- ************************************************** *** -->
    <!-- Notilus project codes export jobDetail definition. -->
    <!-- ************************************************** *** -->

    <bean id="notilusProjectCodesExportJobDetail"
    class="org.springframework.scheduling.quartz.JobDe tailFactoryBean">
    <property name="jobClass"
    value="com.prosodie.nca.scheduler.JobLauncherDetai ls" />
    <property name="group" value="quartz-batch" />
    <!-- <property name="concurrentExectionDisallowed" value="true" /> -->

    <property name="jobDataAsMap">

    <bean class="org.quartz.JobDataMap">
    <constructor-arg>
    <map>
    <entry key="jobName" value="batch.export.notilus.project.codes" />
    <!-- <entry key="input.jpa.queryString" value="select codeBanque from Emetteur" /> -->
    <entry key="maxRetry" value="3" />
    <entry key="listenerDelay" value="2000" />

    <entry key="alarmManagedByJob" value="false" />
    </map>
    </constructor-arg>
    </bean>
    </property>
    </bean>

    <bean id="notilusProjectCodesExempleNca"
    class="org.springframework.scheduling.quartz.JobDe tailFactoryBean">
    <property name="jobClass"
    value="com.prosodie.nca.scheduler.JobLauncherDetai ls" /> <!-- com.prosodie.nca.scheduler.JobLauncherDetailsExemp le -->
    <property name="group" value="quartz-batch" />
    <!-- Concurrent
    <property name="concurrentExectionDisallowed" value="true" /> -->

    <property name="jobDataAsMap">

    <bean class="org.quartz.JobDataMap">
    <constructor-arg>
    <map>
    <entry key="jobName" value="batch.exemple.projet.nca" />
    <!-- <entry key="input.jpa.queryString" value="select codeBanque from Emetteur" /> -->
    <entry key="maxRetry" value="3" />
    <entry key="listenerDelay" value="2000" />
    <!-- The alarmManagedByJob parameter set to false tells the job not to send ExploitAlarms on job failure. -->
    <entry key="alarmManagedByJob" value="false" />
    </map>
    </constructor-arg>
    </bean>
    </property>
    </bean>





    <!-- ************************************************** ************* -->
    <!-- Declare a job listener that will take care of job retries, etc. -->
    <!-- ************************************************** ************* -->

    <bean id="ncaJobListener" class="com.prosodie.nca.scheduler.NcaJobListener">
    <property name="name" value="nca_job_listener"/>
    <meta key="name" value="LISTENER_NAME"/>



    </bean>
    <bean id="jobListener" class="com.prosodie.nca.scheduler.JobFailureListen er" />


    <!-- ************************************************** *** -->
    <!-- Here is the Scheduler Factory that will trigger jobs. -->
    <!-- ************************************************** *** -->


    <bean id="ncaSchedulerFactoryBean" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="schedulerName" value="ncaScheduler" />
    <property name="dataSource" ref="dataSource" />
    <property name="waitForJobsToCompleteOnShutdown" value="true" />
    <property name="overwriteExistingJobs" value="true"/>
    <!-- concurrence
    <property name="DisallowConcurrentExecution" value="true"> -->

    <property name="schedulerContextAsMap">
    <map>
    <entry key="jobLocator" value-ref="jobRegistry" />
    <entry key="jobLauncher" value-ref="jobLauncher" />
    </map>
    </property>



    <property name="triggers">
    <list>
    <!-- Add a trigger definition for Notilus project codes export job. -->
    <bean id="notilusProjectCodesExportCronTrigger"
    class="org.springframework.scheduling.quartz.CronT riggerFactoryBean">
    <property name="jobDetail" ref="notilusProjectCodesExportJobDetail" />
    <!-- <property name="cronExpression" value="0/50 * * * * ?" /> -->
    <property name="cronExpression" value="50 * * * * ?" />
    <property name="group" value="quartz-batch" />
    </bean>


    <!-- Add a trigger definition for Notilus project codes exemple job. -->
    <bean id="notilusProjectCodesExempleCronTrigger" class="org.springframework.scheduling.quartz.CronT riggerFactoryBean">
    <property name="jobDetail" ref="notilusProjectCodesExempleNca" />
    <property name="cronExpression" value="30 * * * * ?"/>

    <property name="group" value="quartz-batch" />
    </bean>




    </list>
    </property>

    <!-- Make the Spring Context Available -->
    <!-- <property name="applicationContextSchedulerContextKey" value="schedulerApplicationContext" /> -->



    </bean>

    </beans>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •