Image du projet 'Socle K-Sup' téléversée
  1. Socle K-Sup
  2. CORE-1749

Intégrer Spring-Batch au produit

    XMLWordImprimable

Informations

    • Nouvelle fonctionnalité
    • Résolution: Résolu
    • Mineur
    • 6.06.00-BETA-01
    • 6.04.14
    • Aucune
    • Aucune
    • Dev, Projets

    Description

      Dans le but de concevoir des jobs administrables, performants et bien séparés des traitements métiers, il serait bien de mettre à disposition le Framework Spring-Batch et le contexte Spring associé dans le Core de telle façon à ce que les extensions projet / produit puissent implémenter des jobs.

      <?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:batch="http://www.springframework.org/schema/batch"
      	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
      	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
                              http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
                              http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
      
      
      	<!-- Configuration des jobs Spring-Batch : http://docs.spring.io/spring-batch/reference/html/configureJob.html -->
      
      	<!-- Initialisation de la base de données du mapping (si nécessaire). Le 
      		script est directement chargé depuis la librairie Spring Batch -->
      	<jdbc:initialize-database data-source="mainDataSource"
      		enabled="true" ignore-failures="ALL">
      		<jdbc:script
      			location="classpath:/org/springframework/batch/core/schema-mysql.sql" />
      	</jdbc:initialize-database>
      
      	<!-- Définition du repository et du lanceur du job -->
      	<batch:job-repository id="jobRepository"
      		data-source="mainDataSource" transaction-manager="transactionManager"
      		isolation-level-for-create="SERIALIZABLE" table-prefix="${springbatch.table.prefix:BATCH_}" />
      
      	<bean id="jobLauncher"
      		class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
      		<property name="jobRepository" ref="jobRepository" />
      	</bean>
      
      	<!-- Registre des Jobs référencés -->
      	<bean id="jobRegistry"
      		class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
      
      	<!-- Référencement automatique -->
      	<bean
      		class="org.springframework.batch.core.configuration.support.AutomaticJobRegistrar">
      		<property name="applicationContextFactories">
      			<bean
      				class="org.springframework.batch.core.configuration.support.ClasspathXmlApplicationContextsFactoryBean">
      				<property name="resources" value="classpath*:*job.xml" />
      			</bean>
      		</property>
      		<property name="jobLoader">
      			<bean
      				class="org.springframework.batch.core.configuration.support.DefaultJobLoader">
      				<property name="jobRegistry" ref="jobRegistry" />
      			</bean>
      		</property>
      	</bean>
      	
      	<!-- Opérateur de jobs -->
      	<bean id="jobOperator"
      		class="org.springframework.batch.core.launch.support.SimpleJobOperator">
      		<property name="jobExplorer">
      			<bean
      				class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean">
      				<property name="dataSource" ref="mainDataSource" />
      				<property name="tablePrefix" value="${springbatch.table.prefix:BATCH_}"/>
      			</bean>
      		</property>		
      		<property name="jobRepository" ref="jobRepository" />
      		<property name="jobRegistry" ref="jobRegistry" />
      		<property name="jobLauncher" ref="jobLauncher" />
      	</bean>
      
      	<!-- Gestion des transactions (pas de transactions supportées par MyISAM 
      		mais supportées pour Spring-Batch : InnoDB). Ce transaction 
      		manager a un gain très important sur l'utilisation d'un ResourcelessTransactionManager 
      		(30% mesurés) -->
      	<bean id="transactionManager"
      		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      		<property name="dataSource" ref="mainDataSource" />
      	</bean>
      
      	<!-- Pool de threads chargés de traiter en parallèle les différentes étapes 
      		du job -->
      	<bean id="parallelTaskExecutor" class="fr.cesi.batch.util.ThreadPoolJobTaskExecutor">
      		<property name="corePoolSize" value="${springbatch.task.core:10}" />
      		<property name="maxPoolSize" value="${springbatch.task.max:10}" />
      	</bean>
      
      </beans>
      

      Pièces jointes

        Activité

          Personnes

            cpoisnel Charles-edouard POISNEL
            cpoisnel Charles-edouard POISNEL
            Votes:
            0 Voter pour ce ticket
            Gérer les observateurs:
            2 Démarre l'observation de ce ticket

            Dates

              Création:
              Mise à jour:
              Résolue: