Réception de notifications d'un planificateur

Divers événements de notification sont générés par un planificateur lorsque celui-ci effectue une opération sur une tâche. Ces notifications sont décrites dans cette rubrique.

Pourquoi et quand exécuter cette tâche

Parmi les événements de notification générés par un planificateur lorsque celui-ci effectue une tâche, citons :
Scheduled
Une tâche a été planifiée.
Purged
Une tâche a définitivement été supprimée du magasin persistant.
Suspended
Une tâche a été interrompue.
Resumed
Une tâche a été reprise.
Complete
Une tâche s'est exécutée en intégralité. S'il s'agissait d'une tâche répétitive, toutes les répétitions ont été effectuées.
Cancelled
Une tâche a été annulée. Elle ne s'exécutera plus.
Firing
Une tâche se prépare à être exécutée.
Fired
L'exécution d'une tâche s'est terminée sans erreur.
Fire failed
L'exécution d'une tâche n'a pas abouti.

Pour recevoir des événements de notification, appelez la méthode setNotificationSink() sur l'interface TaskInfo avant de créer la tâche. La méthode setNotificationSink() permet d'indiquer le bean session qui doit servir de procédure appelée, ainsi qu'un message limitant les événements générés.

Procédure

  1. Créez un bean session NotificationSink. Créez un bean session sans état qui implémente la méthode handleEvent() dans l'interface distante com.ibm.websphere.scheduler.NotificationSink. La méthode handleEvent() est appelée lors du déclenchement de la notification. Les interfaces Home et Remote peuvent être définies comme suit dans le descripteur de déploiement du bean :
    com.ibm.websphere.scheduler.NotificationSinkHome
    com.ibm.websphere.scheduler.NotificationSink

    L'interface NotificationSink définit la méthode suivante :

    public void handleEvent(TaskNotificationInfo task) throws java.rmi.RemoteException;
  2. Spécifiez le bean session de la notification sink avant de soumettre la tâche au planificateur à l'aide de la méthode setNotificationSink() de l'API d'interface TaskInfo.
    Si vous utilisez l'API MBean WASScheduler pour définir la notification sink, le nom JNDI (Java Naming and Directory Interface) doit être le nom JNDI global complet. A l'aide d'un fichier JSP (JavaServer Pages), d'un servlet ou d'un composant EJB (Enterprise JavaBeans), recherchez et définissez la notification sink sur une tâche, comme indiqué dans l'exemple de code suivant :
    TaskInfo taskInfo = ...
    Object o = new InitialContext().lookup("java:comp/env/ejb/NotificationSink");
    NotificationSinkHome home = (NotificationSinkHome )javax.rmi.PortableRemoteObject.narrow
    (o,NotificationSinkHome.class);
    taskInfo.setNotificationSink(home,TaskNotificationInfo.ALL_EVENTS);
    Vous pouvez également utiliser l'outil wsadmin pour définir le bean session de rappel de notification sink illustré dans l'exemple de script JACL suivant :
    # Use the NotificationSinkHome’s Global JNDI name
    # Assume that a TaskInfo was already created...
    $taskInfo setNotificationSink “ejb/MyNotificationSink”
  3. Spécifiez le masque d'événement. Le masque d'événement est indiqué sous la forme d'une mappe de bits d'entier. Vous pouvez utiliser un masque individuel, tel que TaskNotificationInfo.CREATED, TaskNotificationInfo.ALL_EVENTS, pour recevoir tous les événements ou une combinaison d'événements particuliers. Si vous utilisez Java™, votre script ressemblera peut-être à l'exemple suivant :
    int eventMask = TaskNotificationInfo.FIRED | TaskNotificationInfo.COMPLETE;
    taskInfo.setNotificationSink(home,eventMask);
    Si vous utilisez JACL, votre script ressemblera peut-être à l'exemple suivant :
    # Set the event mask based on two event constants.
    set eventmask [expr [java::field com.ibm.websphere.scheduler.TaskNotificationInfo FIRED] +
     [java::field com.ibm.websphere.scheduler.TaskNotificationInfo COMPLETE]]
    
    # Set our Notification Sink based on our global JNDI name AND event mask.
    # Note:  We need to use the full method signature here since the 
    # method resolver can’t always detect the right method.
    $taskInfo {setNotificationSink String int} "ejb/MyNotificationSink" $eventmask

Résultats

Un bean notification sink est à présent défini sur un objet TaskInfo et peut être soumis à un planificateur à l'aide de la méthode create.

Icône indiquant le type de rubrique Rubrique de tâche



Icône d'horodatage Dernière mise à jour: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tsch_usenotificationsink
Nom du fichier : tsch_usenotificationsink.html