SlideShare une entreprise Scribd logo
Entreprise Integration with Spring 
formation proposée par Zenika Paris
Formation officielle Spring Source 
Formation certifiante : donnant le droit de passer la 
certification Spring. 
Durée 4 jours 
Formation 50% théorie, 50% pratique 
Formation animée par Grégory Boissinot
Agenda 
Jour 1 
Introduction aux différents styles d'intégration 
Tâches et ordonnancement 
Remoting 
SOAP web services
Agenda 
Jour 2 
Advanced Web services 
RESTful web services 
Working with JMS 
Transactional JMS
Agenda 
Jour 3 
Global transaction management (XA & JTA) 
Spring Integration
Agenda 
Jour 4 
Spring Batch 
Spring Batch Admin
Spring Batch 
Philosophie de traitement répétitif de volumes importants de 
données sans interactions humaines.
Présentation du cadre de spring batch 
Un Job est constitué de Steps. 
Une Step est constituée de ItemReader, ItemProcessor, 
ItemWriter 
Une JobInstance est constituée d'un Job et de JobParameters 
Une tentative exécution d'une JobInstance est une 
JobExecution 
Les meta data d'une JobExecution sont enregistréee dans le 
JobRepository 
Le JobLauncher est en charge de lancer les Jobs
Architecture
Présentation d'une Step 
Traitement par lot : Chunk oriented Step.
Configuration d'un job 
Traitement par lot : Chunk oriented Step. 
<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" 
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring‐<batch:job id="diningRequestsJob"> 
<batch:step id="diningRequestsStep"> 
<batch:tasklet start‐limit="3"> 
<batch:chunk reader="diningRequestsReader" 
writer="reportWriter" 
commit‐interval="10"> 
<batch:processor adapter‐method="rewardAccountFor"> 
<ref bean="rewardNetwork"/> 
</batch:processor> 
</batch:chunk> 
</batch:tasklet> 
</batch:step> 
</batch:job>
ItemReader & ItemWriter 
off-the-shelf components 
file 
xml 
jdbc 
Hibernate 
JMS 
Possibilité de créer ces propres reader et writer en implémentant 
les interfaces : ItemReader et ItemWriter
ItemReader & ItemWriter 
ItemReader 
AmqpItemReader AggregateItemReader 
FlatFileItemReader HibernateCursorItemReader 
HibernatePagingItemReader IbatisPagingItemReader 
ItemReaderAdapter JdbcCursorItemReader 
JdbcPagingItemReader JmsItemReader 
JpaPagingItemReader ListItemReader 
MongoItemReader Neo4jItemReader 
RepositoryItemReader StoredProcedureItemReader 
StaxEventItemReader
ItemReader & ItemWriter 
ItemWriter 
AbstractItemStreamItemWriter AmqpItemWriter 
CompositeItemWriter FlatFileItemWriter 
GemfireItemWriter HibernateItemWriter 
IbatisBatchItemWriter ItemWriterAdapter 
JdbcBatchItemWriter JmsItemWriter 
JpaItemWriter MimeMessageItemWriter 
MongoItemWriter Neo4jItemWriter 
StaxEventItemWriter RepositoryItemWriter
JobRepository 
Enregistrement des informations des JobExecution : Job 
Context, Step Context, Job Instance, Job Params. 
Enregistrement volatile (en mémoire) ou persisté (en base de 
données relationnelle).
MapJobRepositoryFactoryBean 
A FactoryBean that automates the creation of a 
SimpleJobRepository using non-persistent in-memory DAO 
implementations. 
<bean id="jobRegistry" class="org.springframework.batch...MapJobRegistry"> 
<property name="transactionManager" ref="transactionManager"></property> 
</bean>
JobRepositoryFactoryBean 
A FactoryBean that automates the creation of a 
SimpleJobRepository using JDBC DAO implementations which 
persist batch metadata in database. 
<bean id="jobRepository" class="org...JobRepositoryFactoryBean"> 
<property name="dataSource" ref="dataSource"/> 
</bean>
Restart and Recovery 
Gestion de l'état et des exécutions pour permettre le 
redémarrage et la récupération en cas d'erreur.
ExecutionContext 
Utilisation de Job ExecutionContext fournissant l'état initial 
pour un redémarrage. Step ExecutionContext committé à la fin 
de chaque chunk, permet de reprendre une exécution.
Stateful ItemReader/Writer 
Permet d'enregister au sein du context d'exécution des valeurs 
afin de permettre la reprise. 
Attention à la gestion de l'état si les steps sont multi-threadées. 
Interface StepExecutionListener avec les méthodes : 
void beforeStep(StepExecution stepExecution) 
ExitStatus afterStep(StepExecution stepExecution) 
BeforeStep AfterStep 
Possibilité d'utiliser les annotations et
ItemStream 
Facilitation de la gestion d'état pour ItemReader : 
open() appelé avant chaque appel à la méthode read 
update() appelé à la fin de chaque chunk, avant le commit 
close() appelé à la fin de chaque step 
Interface implémentée par la plupart des readers founit. 
Exemple: 
FlatFileItemReader 
Restartable ItemReader that reads lines from input 
setResource(Resource)
FieldSet et FieldSetMapper 
Dans le cadre de la lecture de fichier, Spring fournit une 
représentation de la ligne lue grâce à un wrapper : FieldSet. 
Le FieldSet est ensuite transformé sous forme d'objet grâce à 
un FieldSetMapper.
FieldSet et FieldSetMapper 
Spring founit des mappers tels que : 
PassthourghFieldSetMapper: retourne le fieldset tel quel. 
BeanWrapperFieldSetMapper: utiliser le noms des champs 
pour mapper avec les propriétes d'un objet.
Partage d'état entre Step 
Utilisation du JobExecutionContext 
@BeforeStep 
public void retrieveInterstepData(StepExecution stepExecution) { 
JobExecution jobExecution = stepExecution.getJobExecution(); 
ExecutionContext jobContext = jobExecution.getExecutionContext(); 
jobContext.get("sharedObject"); 
}
Partage d'état entre Step 
Utilisation du ExecutionContextPromotionListener 
<bean id="promotionListener" class="org...ExecutionContextPromotionListener"> 
<property name="key" value="myKey" /> 
</bean>
Scope Step 
Utilisation de SpEL pour injecter dynamiquement les parametres 
du job. 
<bean id="reader" scope="step" class="MyReader"> 
<property name="resource" value="#{jobParameters['input.resource.path']}"> 
</property> 
</bean>
Skip, Retry, Repeat, Restart 
Repeat : lorsqu'on souhaite itérer sur une collection de 
ressources 
Retry : lors d'une erreur non attribuable à la tâche 
Skip : toutes les erreurs ne sont pas causes d'échec 
Restart : redémarrage
Repeat 
On ne parle plus d'une chunk oriented step. 
package org.springframework.batch.core.step.tasklet; 
import org.springframework.batch.core.StepContribution; 
import org.springframework.batch.core.scope.context.ChunkContext; 
import org.springframework.batch.repeat.RepeatStatus; 
public interface Tasklet { 
RepeatStatus execute(StepContribution contribution, 
ChunkContext chunkContext) throws Exception; 
}
Retry 
<step id="step1"> 
<tasklet> 
<chunk reader="reader" writer="writer" commit‐interval="20" retry‐limit="3"> 
<retryable‐exception‐classes> 
<include class="org...DeadLockLoserDataAccessException" /> 
</retryable‐exception‐classes> 
</chunk> 
</tasklet> 
</step>
Skip 
<step id="step1"> 
<tasklet> 
<chunk reader="reader" writer="writer" commit‐interval="20" skip‐limit="3"> 
<skippable‐exception‐classes> 
<include class="org...FlatFileParseException" /> 
</skippable‐exception‐classes> 
</chunk> 
</tasklet> 
</step>
Restart 
Spring Batch utilise le contexte persisté où relance la tâche 
from scratch. 
Possibilité de désactiver le redémarrage de steps <tasklet 
allow‐start‐if‐complete="true"> 
Possibilité de limiter le nombre de démarrage d'une step : 
<tasklet start‐limit="1">
Listeners 
Callback au cours de l'exécution (logging, auditing, state, error 
handling, etc.) 
JobExecutionListener 
StepListener 
StepExecution-, Chunk-, Item(Read|Processor|Writer)- et 
SkipListener
Listeners 
AfterChunk AfterChunkError AfterJob AfterProcess 
AfterRead AfterStep AfterWrite BeforeChunk 
BeforeJob BeforeProcess BeforeRead BeforeStep 
BeforeWrite OnProcessError OnReadError OnSkipInProcess 
OnSkipInRead OnSkipInWrite OnWriteError
Pour allez plus loin 
JobParametersValidator JobExplorer 
JobOperator CommandLineJobRunner 
JobExecutionDecider
JobExplorer 
public interface JobExplorer { 
List<JobInstance> getJobInstances(String jobName, int start, int count); 
JobExecution getJobExecution(Long executionId); 
StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId); 
JobInstance getJobInstance(Long instanceId); 
List<JobExecution> getJobExecutions(JobInstance jobInstance); 
Set<JobExecution> findRunningJobExecutions(String jobName); 
}
JobOperator 
public interface JobOperator { 
List<Long> getExecutions(long instanceId) throws NoSuchJobInstanceException; 
List<Long> getJobInstances(String jobName, int start, int count) 
throws NoSuchJobException; 
Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException; 
String getParameters(long executionId) throws NoSuchJobExecutionException; 
Long start(String jobName, String parameters) 
throws NoSuchJobException, JobInstanceAlreadyExistsException; 
Long restart(long executionId) 
throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, 
NoSuchJobException, JobRestartException; 
Long startNextInstance(String jobName) 
throws NoSuchJobException, JobParametersNotFoundException, JobRestartException, 
JobExecutionAlreadyRunningException, JobInstanceAlreadyCompleteException; 
boolean stop(long executionId) 
throws NoSuchJobExecutionException, JobExecutionNotRunningException; 
String getSummary(long executionId) throws NoSuchJobExecutionException; 
Map<Long, String> getStepExecutionSummaries(long executionId) 
throws NoSuchJobExecutionException;
Scaling and parallel processing 
A utiliser seulement en cas de nécessaire besoin. 
Multi-threaded Step 
Parallel Step 
Remote Chunking Step (spring-batch-integration) 
Partitionning Step
Multi-threaded Step 
Il suffit d'ajouter un 
TaskExecutor 
<step id="loading"> 
<tasklet task‐executor="taskExecutor" throttle‐limit="20" /> 
</step> 
Item(Reader|Writer|Processor) doivent être stateless ou 
thread-safe 
La plupart des Items fournit par Spring Batch ne sont pas 
thread-safe 
throttle-limit correspond au nombre de threads disponibles
Parallel Step 
<job id="job"> 
<split id="split" task‐executor="taskExecutor" next="step4"> 
<flow> 
<step id="step1" parent="s1" next="step2" /> 
<step id="step2" parent="s2" /> 
</flow> 
<flow> 
<step id="step3" parent="s3" /> 
</flow> 
</split> 
<step id="step4" parent="s4" /> 
</job>
Partitioning SPI 
Cela consiste en : 
Une implémentation de Step dite PartitionStep 
PartitionHandler 
StepExecutionSplitter
Partitioning SPI
Spring Batch Admin 
Sous projet de Spring Batch 
Sous la forme d'un war ou d'un jar 
fournit une interface web et une API RESTFul pour inspecter 
les jobs 
se branche sur les meta datas persistées par le 
JobRepository
Spring Batch Admin
Spring Batch Admin
Spring Batch Admin

Contenu connexe

PDF
CocoaHeads Rennes #16: OHHTTPStubs
KEY
Spring Batch 17-05-2011
PPT
Spring mvc
PPTX
Hibernate jpa
PPTX
Spring Batch Avance
PPT
Formation jpa-hibernate-spring-data
PPTX
Gatling Tool in Action at DevoxxFR 2012
PPTX
Spring ioc
CocoaHeads Rennes #16: OHHTTPStubs
Spring Batch 17-05-2011
Spring mvc
Hibernate jpa
Spring Batch Avance
Formation jpa-hibernate-spring-data
Gatling Tool in Action at DevoxxFR 2012
Spring ioc

Tendances (14)

PDF
Spring Batch ParisJUG
PPTX
Workshop Spring - Session 4 - Spring Batch
PPT
Ysance conference - cloud computing - aws - 3 mai 2010
PPTX
Realtime Web avec Kafka, Spark et Mesos
PDF
WS User Group - Spring Batch - Xebia
PDF
Introduction au langage Go
PPTX
Les Streams de Java 8
PDF
Introduction à React
PPTX
PPTX
Jprofiler
PPTX
Paris JUG Spring Batch
PPTX
Chtijug springbatch 2011
PPTX
Les tests comportementaux avec aspnet core
PPTX
Retours Devoxx France 2016
Spring Batch ParisJUG
Workshop Spring - Session 4 - Spring Batch
Ysance conference - cloud computing - aws - 3 mai 2010
Realtime Web avec Kafka, Spark et Mesos
WS User Group - Spring Batch - Xebia
Introduction au langage Go
Les Streams de Java 8
Introduction à React
Jprofiler
Paris JUG Spring Batch
Chtijug springbatch 2011
Les tests comportementaux avec aspnet core
Retours Devoxx France 2016
Publicité

En vedette (8)

PPT
Spring Batch Introduction
PDF
Spring Batch - concepts de base
PPTX
Parallel batch processing with spring batch slideshare
PDF
Spring Batch - Lessons Learned out of a real life banking system.
PPT
Spring Batch 2.0
PDF
Site JEE de ECommerce Basé sur Spring IOC MVC Security JPA Hibernate
PPTX
Workshop Spring - Session 5 - Spring Integration
PDF
Support de cours Spring M.youssfi
Spring Batch Introduction
Spring Batch - concepts de base
Parallel batch processing with spring batch slideshare
Spring Batch - Lessons Learned out of a real life banking system.
Spring Batch 2.0
Site JEE de ECommerce Basé sur Spring IOC MVC Security JPA Hibernate
Workshop Spring - Session 5 - Spring Integration
Support de cours Spring M.youssfi
Publicité

Similaire à Spring Batch (20)

PPTX
Introduction au Spring microservices Batch.pptx
PPTX
Introduction au Spring Batch pour microservices.pptx
PPTX
Introduction au Spring Batch pour microservices.pptx
PPTX
Introduction au Spring Batch pour microservices.pptx
PDF
Spring Batch - Julien Jakubowski - November 2010
PPTX
Spring & SpringBatch FR
PPT
Presentation Spring, Spring MVC
PPTX
Les dessous du framework spring
PPTX
Workshop Spring - Session 1 - L'offre Spring et les bases
PDF
tp-spring.pdf
PDF
tp-spring.pdf
PDF
Sug spring batch
PPTX
Workshop Spring 3 - Tests et techniques avancées du conteneur Spring
PDF
Spring 3 en production
PPS
Building Entreprise App With Spring Portfolio
PPTX
Workshop spring session 2 - La persistance au sein des applications Java
PPT
Presentation Spring
PDF
Application Spring MVC/IOC & Hibernate
PPT
Alt.net spring.net
Introduction au Spring microservices Batch.pptx
Introduction au Spring Batch pour microservices.pptx
Introduction au Spring Batch pour microservices.pptx
Introduction au Spring Batch pour microservices.pptx
Spring Batch - Julien Jakubowski - November 2010
Spring & SpringBatch FR
Presentation Spring, Spring MVC
Les dessous du framework spring
Workshop Spring - Session 1 - L'offre Spring et les bases
tp-spring.pdf
tp-spring.pdf
Sug spring batch
Workshop Spring 3 - Tests et techniques avancées du conteneur Spring
Spring 3 en production
Building Entreprise App With Spring Portfolio
Workshop spring session 2 - La persistance au sein des applications Java
Presentation Spring
Application Spring MVC/IOC & Hibernate
Alt.net spring.net

Spring Batch

  • 1. Entreprise Integration with Spring formation proposée par Zenika Paris
  • 2. Formation officielle Spring Source Formation certifiante : donnant le droit de passer la certification Spring. Durée 4 jours Formation 50% théorie, 50% pratique Formation animée par Grégory Boissinot
  • 3. Agenda Jour 1 Introduction aux différents styles d'intégration Tâches et ordonnancement Remoting SOAP web services
  • 4. Agenda Jour 2 Advanced Web services RESTful web services Working with JMS Transactional JMS
  • 5. Agenda Jour 3 Global transaction management (XA & JTA) Spring Integration
  • 6. Agenda Jour 4 Spring Batch Spring Batch Admin
  • 7. Spring Batch Philosophie de traitement répétitif de volumes importants de données sans interactions humaines.
  • 8. Présentation du cadre de spring batch Un Job est constitué de Steps. Une Step est constituée de ItemReader, ItemProcessor, ItemWriter Une JobInstance est constituée d'un Job et de JobParameters Une tentative exécution d'une JobInstance est une JobExecution Les meta data d'une JobExecution sont enregistréee dans le JobRepository Le JobLauncher est en charge de lancer les Jobs
  • 10. Présentation d'une Step Traitement par lot : Chunk oriented Step.
  • 11. Configuration d'un job Traitement par lot : Chunk oriented Step. <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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring‐<batch:job id="diningRequestsJob"> <batch:step id="diningRequestsStep"> <batch:tasklet start‐limit="3"> <batch:chunk reader="diningRequestsReader" writer="reportWriter" commit‐interval="10"> <batch:processor adapter‐method="rewardAccountFor"> <ref bean="rewardNetwork"/> </batch:processor> </batch:chunk> </batch:tasklet> </batch:step> </batch:job>
  • 12. ItemReader & ItemWriter off-the-shelf components file xml jdbc Hibernate JMS Possibilité de créer ces propres reader et writer en implémentant les interfaces : ItemReader et ItemWriter
  • 13. ItemReader & ItemWriter ItemReader AmqpItemReader AggregateItemReader FlatFileItemReader HibernateCursorItemReader HibernatePagingItemReader IbatisPagingItemReader ItemReaderAdapter JdbcCursorItemReader JdbcPagingItemReader JmsItemReader JpaPagingItemReader ListItemReader MongoItemReader Neo4jItemReader RepositoryItemReader StoredProcedureItemReader StaxEventItemReader
  • 14. ItemReader & ItemWriter ItemWriter AbstractItemStreamItemWriter AmqpItemWriter CompositeItemWriter FlatFileItemWriter GemfireItemWriter HibernateItemWriter IbatisBatchItemWriter ItemWriterAdapter JdbcBatchItemWriter JmsItemWriter JpaItemWriter MimeMessageItemWriter MongoItemWriter Neo4jItemWriter StaxEventItemWriter RepositoryItemWriter
  • 15. JobRepository Enregistrement des informations des JobExecution : Job Context, Step Context, Job Instance, Job Params. Enregistrement volatile (en mémoire) ou persisté (en base de données relationnelle).
  • 16. MapJobRepositoryFactoryBean A FactoryBean that automates the creation of a SimpleJobRepository using non-persistent in-memory DAO implementations. <bean id="jobRegistry" class="org.springframework.batch...MapJobRegistry"> <property name="transactionManager" ref="transactionManager"></property> </bean>
  • 17. JobRepositoryFactoryBean A FactoryBean that automates the creation of a SimpleJobRepository using JDBC DAO implementations which persist batch metadata in database. <bean id="jobRepository" class="org...JobRepositoryFactoryBean"> <property name="dataSource" ref="dataSource"/> </bean>
  • 18. Restart and Recovery Gestion de l'état et des exécutions pour permettre le redémarrage et la récupération en cas d'erreur.
  • 19. ExecutionContext Utilisation de Job ExecutionContext fournissant l'état initial pour un redémarrage. Step ExecutionContext committé à la fin de chaque chunk, permet de reprendre une exécution.
  • 20. Stateful ItemReader/Writer Permet d'enregister au sein du context d'exécution des valeurs afin de permettre la reprise. Attention à la gestion de l'état si les steps sont multi-threadées. Interface StepExecutionListener avec les méthodes : void beforeStep(StepExecution stepExecution) ExitStatus afterStep(StepExecution stepExecution) BeforeStep AfterStep Possibilité d'utiliser les annotations et
  • 21. ItemStream Facilitation de la gestion d'état pour ItemReader : open() appelé avant chaque appel à la méthode read update() appelé à la fin de chaque chunk, avant le commit close() appelé à la fin de chaque step Interface implémentée par la plupart des readers founit. Exemple: FlatFileItemReader Restartable ItemReader that reads lines from input setResource(Resource)
  • 22. FieldSet et FieldSetMapper Dans le cadre de la lecture de fichier, Spring fournit une représentation de la ligne lue grâce à un wrapper : FieldSet. Le FieldSet est ensuite transformé sous forme d'objet grâce à un FieldSetMapper.
  • 23. FieldSet et FieldSetMapper Spring founit des mappers tels que : PassthourghFieldSetMapper: retourne le fieldset tel quel. BeanWrapperFieldSetMapper: utiliser le noms des champs pour mapper avec les propriétes d'un objet.
  • 24. Partage d'état entre Step Utilisation du JobExecutionContext @BeforeStep public void retrieveInterstepData(StepExecution stepExecution) { JobExecution jobExecution = stepExecution.getJobExecution(); ExecutionContext jobContext = jobExecution.getExecutionContext(); jobContext.get("sharedObject"); }
  • 25. Partage d'état entre Step Utilisation du ExecutionContextPromotionListener <bean id="promotionListener" class="org...ExecutionContextPromotionListener"> <property name="key" value="myKey" /> </bean>
  • 26. Scope Step Utilisation de SpEL pour injecter dynamiquement les parametres du job. <bean id="reader" scope="step" class="MyReader"> <property name="resource" value="#{jobParameters['input.resource.path']}"> </property> </bean>
  • 27. Skip, Retry, Repeat, Restart Repeat : lorsqu'on souhaite itérer sur une collection de ressources Retry : lors d'une erreur non attribuable à la tâche Skip : toutes les erreurs ne sont pas causes d'échec Restart : redémarrage
  • 28. Repeat On ne parle plus d'une chunk oriented step. package org.springframework.batch.core.step.tasklet; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.repeat.RepeatStatus; public interface Tasklet { RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception; }
  • 29. Retry <step id="step1"> <tasklet> <chunk reader="reader" writer="writer" commit‐interval="20" retry‐limit="3"> <retryable‐exception‐classes> <include class="org...DeadLockLoserDataAccessException" /> </retryable‐exception‐classes> </chunk> </tasklet> </step>
  • 30. Skip <step id="step1"> <tasklet> <chunk reader="reader" writer="writer" commit‐interval="20" skip‐limit="3"> <skippable‐exception‐classes> <include class="org...FlatFileParseException" /> </skippable‐exception‐classes> </chunk> </tasklet> </step>
  • 31. Restart Spring Batch utilise le contexte persisté où relance la tâche from scratch. Possibilité de désactiver le redémarrage de steps <tasklet allow‐start‐if‐complete="true"> Possibilité de limiter le nombre de démarrage d'une step : <tasklet start‐limit="1">
  • 32. Listeners Callback au cours de l'exécution (logging, auditing, state, error handling, etc.) JobExecutionListener StepListener StepExecution-, Chunk-, Item(Read|Processor|Writer)- et SkipListener
  • 33. Listeners AfterChunk AfterChunkError AfterJob AfterProcess AfterRead AfterStep AfterWrite BeforeChunk BeforeJob BeforeProcess BeforeRead BeforeStep BeforeWrite OnProcessError OnReadError OnSkipInProcess OnSkipInRead OnSkipInWrite OnWriteError
  • 34. Pour allez plus loin JobParametersValidator JobExplorer JobOperator CommandLineJobRunner JobExecutionDecider
  • 35. JobExplorer public interface JobExplorer { List<JobInstance> getJobInstances(String jobName, int start, int count); JobExecution getJobExecution(Long executionId); StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId); JobInstance getJobInstance(Long instanceId); List<JobExecution> getJobExecutions(JobInstance jobInstance); Set<JobExecution> findRunningJobExecutions(String jobName); }
  • 36. JobOperator public interface JobOperator { List<Long> getExecutions(long instanceId) throws NoSuchJobInstanceException; List<Long> getJobInstances(String jobName, int start, int count) throws NoSuchJobException; Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException; String getParameters(long executionId) throws NoSuchJobExecutionException; Long start(String jobName, String parameters) throws NoSuchJobException, JobInstanceAlreadyExistsException; Long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException, JobRestartException; Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersNotFoundException, JobRestartException, JobExecutionAlreadyRunningException, JobInstanceAlreadyCompleteException; boolean stop(long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException; String getSummary(long executionId) throws NoSuchJobExecutionException; Map<Long, String> getStepExecutionSummaries(long executionId) throws NoSuchJobExecutionException;
  • 37. Scaling and parallel processing A utiliser seulement en cas de nécessaire besoin. Multi-threaded Step Parallel Step Remote Chunking Step (spring-batch-integration) Partitionning Step
  • 38. Multi-threaded Step Il suffit d'ajouter un TaskExecutor <step id="loading"> <tasklet task‐executor="taskExecutor" throttle‐limit="20" /> </step> Item(Reader|Writer|Processor) doivent être stateless ou thread-safe La plupart des Items fournit par Spring Batch ne sont pas thread-safe throttle-limit correspond au nombre de threads disponibles
  • 39. Parallel Step <job id="job"> <split id="split" task‐executor="taskExecutor" next="step4"> <flow> <step id="step1" parent="s1" next="step2" /> <step id="step2" parent="s2" /> </flow> <flow> <step id="step3" parent="s3" /> </flow> </split> <step id="step4" parent="s4" /> </job>
  • 40. Partitioning SPI Cela consiste en : Une implémentation de Step dite PartitionStep PartitionHandler StepExecutionSplitter
  • 42. Spring Batch Admin Sous projet de Spring Batch Sous la forme d'un war ou d'un jar fournit une interface web et une API RESTFul pour inspecter les jobs se branche sur les meta datas persistées par le JobRepository