ComposantsComponents

ComposantsComponents › OrchestrationOrchestration

tPostjob

tPostjob

OrchestrationOrchestration

Démarre le post-job : ce qu'il déclenche s'exécute après tous les autres sous-jobs du job, même quand l'un d'eux a échoué. C'est l'endroit du ménage : fermer ce qui a été ouvert, déplacer ou supprimer des fichiers de travail, écrire un message de fin. Starts the postjob: what it triggers runs after all the other subjobs of the job, even when one of them failed. It is the place for cleaning up: close what was opened, move or delete work files, write an end message.

EntréeInput

aucunenone il commence le post-jobit starts the postjob

SortieOutput

aucunenone pas de fluxno flow

Déclencheurs en sortieOutput triggers

On Component Ok un seul liena single link

UtilisationUsage

Le post-jobThe postjob

OnComponentOk OnSubjobOk tPostjob_1 tFileCopy_1 tJava_1

Le tPostjob ne contient pas de code : il sert de point de départ. Le composant qu'il déclenche commence le post-job ; les sous-jobs qui en découlent (On Subjob Ok, Run if…) en font partie. The tPostjob contains no code: it is a starting point. The component it triggers starts the postjob; the subjobs that follow from it (On Subjob Ok, Run if…) belong to it.

Ordre d'exécution d'un jobExecution order of a job

  1. le tContextLoad implicite (onglet Job › Extra), s'il est activé ;the implicit tContextLoad (Job › Extra tab), if activated;
  2. le pré-job (tPrejob) ;the prejob (tPrejob);
  3. les autres sous-jobs ;the other subjobs;
  4. le post-job.the postjob.

Avec l'exécution multi-thread du job, le post-job attend que tous les sous-jobs parallèles soient finis. With multi-thread execution of the job, the postjob waits for all the parallel subjobs to be finished.

  1. Déposez le tPostjob depuis la famille Orchestration de la palette. Drop the tPostjob from the Orchestration family of the palette.
  2. Reliez-le au premier composant du ménage : clic droit › Déclencher › On Component Ok. Connect it to the first component of the cleanup: right-click › Trigger › On Component Ok.
  3. Enchaînez les autres étapes par On Subjob Ok. Les sous-jobs principaux n'ont pas besoin d'être reliés au post-job. Chain the other steps with On Subjob Ok. The main subjobs do not need to be connected to the postjob.

ParamètresSettings

Le tPostjob n'a aucun paramètre : ni paramètre simple, ni paramètre avancé, ni variable globale. Un job n'accepte qu'un seul tPostjob. The tPostjob has no settings: no basic setting, no advanced setting, no global variable. A job accepts only one tPostjob.

ExemplesExamples

Chaque tJava écrit le message indiqué. Sorties copiées depuis une exécution du job ; dans les erreurs, le nom du job est remplacé par MyJob et les traces d'exception sont abrégées. Each tJava writes the message shown. Outputs copied from a run of the job; in the errors, the job name is replaced with MyJob and the exception traces are shortened.

Ordre d'exécutionExecution order

OnComponentOk OnComponentOk OnSubjobOk tJava_1 "Main subjob: processing" tPostjob_1 tJava_2 "Postjob: closing" tPrejob_1 tJava_3 "Prejob: step 1" tJava_4 "Prejob: step 2"
Prejob: step 1
Prejob: step 2
Main subjob: processing
Postjob: closing

Après une exceptionAfter an exception

Le sous-job principal (tJava_1) lève une exception ; le post-job écrit Postjob: closing. The main subjob (tJava_1) throws an exception; the postjob writes Postjob: closing.

System.out.println("Main subjob: start");
if (true) {
    throw new RuntimeException("Database unavailable");
}
Main subjob: start
Exception in component tJava_1 (MyJob)
java.lang.RuntimeException: Database unavailable
	at …
Postjob: closing

Le post-job s'exécute malgré l'erreur ; le job se termine avec le code 1. The postjob runs despite the error; the job ends with code 1.

Après un tDie : le code de retour devient 1After a tDie: the exit code becomes 1

OnSubjobOk tJava_1 tDie_1

tDie_1 : message "File not found", code d'erreur 4. Avec un post-job : tDie_1: message "File not found", error code 4. With a postjob:

Main subjob: start
File not found
Postjob: closing

Le job se termine avec le code 1 ; sans le tPostjob, le même job se termine avec le code 4 du tDie. Chaque sous-job efface le code d'erreur avant de démarrer, le post-job compris : seul reste l'état d'échec, qui donne 1. Un ordonnanceur qui lit le code du tDie ne le voit donc plus. The job ends with code 1; without the tPostjob, the same job ends with the tDie code 4. Each subjob clears the error code before starting, the postjob included: only the failure status remains, which gives 1. A scheduler that reads the tDie code therefore no longer sees it.

ConseilsTips

Pas après un arrêt de la JVMNot after the JVM stops

Un tDie avec Quitter la JVM immédiatement arrête tout sur-le-champ : le post-job ne s'exécute pas (voir l'exemple du tPrejob). Le post-job ne passe pas non plus quand le job est tué de l'extérieur. A tDie with Exit the JVM immediately stops everything at once: the postjob does not run (see the tPrejob example). The postjob does not run either when the job is killed from outside.

Un ménage qui supporte l'échecA cleanup that copes with failure

Le post-job peut suivre un sous-job interrompu au milieu : un fichier peut manquer, une connexion ne pas être ouverte. Testez ce qui doit l'être avant d'agir (un Run if, une option du composant pour ne pas échouer sur un fichier absent). The postjob can follow a subjob stopped halfway: a file may be missing, a connection may not be open. Test what needs to be tested before acting (a Run if, a component option not to fail on a missing file).

Voir aussiSee also

D'autres composants de la famille Orchestration : Other components of the Orchestration family: