2014-04-29 20 views
5

Ho implementato il partizionamento batch primaverile per una singola procedura in cui una fase master delega il proprio lavoro a diversi thread slave che vengono eseguiti in parallelo. Come mostrato nell'immagine seguente (riferimento Spring docs) enter image description here Ora, se ho più passaggi che devono essere eseguiti in parallelo? Come configurarli nella configurazione batch? La mia configurazione corrente èPart batch di primavera Partendo con più passaggi in parallelo?

<batch:job id="myJob" restartable="true" job-repository="jobRepository" > 
     <batch:listeners> 
      <batch:listener ref="myJoblistener"></batch:listener> 
     </batch:listeners> 

     <batch:step id="my-master-step"> 
      <batch:partition step="my-step" partitioner="my-step-partitioner" handler="my-partitioner-handler"> 
      </batch:partition> 
     </batch:step> 
    </batch:job> 

    <batch:step id="my-step" > 
     <batch:tasklet ref="myTasklet" transaction-manager="transactionManager" > 
     </batch:tasklet> 
     <batch:listeners> 
      <batch:listener ref="myStepListener"></batch:listener> 
     </batch:listeners> 
    </batch:step> 

miei schemi architettura dovrebbe essere come segue immagine: enter image description here

Non sono sicuro, anche se è possibile utilizzando le idee primavera batch.Any o io sono modo sopra la mia testa da implementare Grazie.

+0

Salve, Vedi questo post che descrive come utilizzare il flusso e gli elementi elem dividere. Sto cercando di fare esattamente lo stesso di te, ma sono ancora bloccato con esso. http://javaetmoi.com/2012/12/parallelisation-de-traitements-batchs-spring-batch – emeraldjava

+0

Questo è un secondo post che ho trovato relativo a questo argomento. http://forum.spring.io/forum/spring-projects/batch/80527-defining-a-flow-inside-a-partitionstep – emeraldjava

+0

Ho avuto un problema simile, per favore date un'occhiata a http://stackoverflow.com/questions/33121176/spring-batch-flowstep-in-partitioner-restart-issue/33125360 # 33125360 – mremond

risposta

3

È possibile provare quanto segue.

<batch:job id="myJob" restartable="true" job-repository="jobRepository" > 
     <batch:listeners> 
      <batch:listener ref="myJoblistener"></batch:listener> 
     </batch:listeners> 

     <batch:step id="my-master-step"> 
      <batch:partition step="my-step" partitioner="my-step-partitioner" handler="my-partitioner-handler"> 
      </batch:partition> 
     </batch:step> 
    </batch:job> 

    <batch:step id="my-step" > 
     <batch:job ref="MyChildJob" job-launcher="jobLauncher" 
       job-parameters-extractor="jobParametersExtractor" /> 
     <batch:listeners> 
      <batch:listener ref="myStepListener"></batch:listener> 
     </batch:listeners> 
    </batch:step> 

    <batch:job id="MyChildJob" restartable="false" 
     xmlns="http://www.springframework.org/schema/batch"> 
     <batch:step id="MyChildStep1" next="MyChildStep2"> 
      <batch:tasklet ref="MyChildStep1Tasklet" transaction-manager="transactionManager" > 
      </batch:tasklet> 
     </batch:step> 

     <batch:step id="MyChildStep2" next="MyChildStep3"> 
      <batch:tasklet ref="MyChildStep2Tasklet" transaction-manager="transactionManager" > 
      </batch:tasklet> 
     </batch:step> 

     <batch:step id="MyChildStep3"> 
      <batch:tasklet ref="MyChildStep3Tasklet" transaction-manager="transactionManager" > 
      </batch:tasklet> 
     </batch:step> 

    </batch:job> 
+0

Non penso che funzionerebbe ... Osservando la tua configurazione ogni tasklet sta eseguendo un lavoro diverso ... Questo è non desiderabile. Ho bisogno di un singolo lavoro batch con comportamento sopra menzionato .. grazie –

+0

Ho configurato lo stesso modo e lavorando bene in produzione. Se non è necessario come lavoro separato, configurarlo come flusso. Il flusso contiene tutti e tre i passaggi. –

+0

Ciao @ DanglingPiyush. Ho risolto il tuo problema. Ho lo stesso requisito. Puoi aiutarmi – pppavan

-1

avevo requisito simile e risolto usando sotto requisito

<batch:job id="cycleJob"> 
     <batch:step id="zStep" next="gStep"> 
      <batch:partition partitioner="zPartitioner"> 
       <batch:step> 
        <batch:tasklet throttle-limit="1"> 
         <batch:chunk processor="itemProcessor" reader="zReader" writer="itemWriter" commit-interval="1"> 
         </batch:chunk> 
        </batch:tasklet> 
       </batch:step> 
       <batch:handler task-executor="taskExecutor" grid-size="${maxThreads}" /> 
      </batch:partition> 
     </batch:step> 
     <batch:step id="gStep" parent="zStep" next="yStep"> 
      <batch:partition partitioner="gPartitioner"> 
       <batch:step> 
        <batch:tasklet throttle-limit="1"> 
         <batch:chunk processor="itemProcessor" reader="gReader" writer="itemWriter" commit-interval="1"> 
         </batch:chunk> 
        </batch:tasklet> 
       </batch:step> 
       <batch:handler task-executor="taskExecutor" grid-size="${maxThreads}" /> 
      </batch:partition> 
     </batch:step> 
</batch:job> 
Problemi correlati