Ce contenu n'est pas disponible dans la langue sélectionnée.

4.3. Events


Both the stateful and stateless knowledge sessions provide methods that allow you to register and remove listeners. Use ProcessEventListener objects to listen to process-related events (like starting or completing a process or entering or leaving a node.) Here are the different methods for it:
public interface ProcessEventListener {

  void beforeProcessStarted( ProcessStartedEvent event );
  void afterProcessStarted( ProcessStartedEvent event );
  void beforeProcessCompleted( ProcessCompletedEvent event );
  void afterProcessCompleted( ProcessCompletedEvent event );
  void beforeNodeTriggered( ProcessNodeTriggeredEvent event );
  void afterNodeTriggered( ProcessNodeTriggeredEvent event );
  void beforeNodeLeft( ProcessNodeLeftEvent event );
  void afterNodeLeft( ProcessNodeLeftEvent event );

}
Copy to Clipboard Toggle word wrap
You can create an audit log based on the information provided by these process listeners. Red Hat provides you with the following ones out-of the-box:
  1. Console logger: this outputs every event to the console.
  2. File logger: this outputs every event to an XML file. This log file might then be used in the IDE to generate a tree-based visualization of the events that occurred during execution.
  3. Threaded file logger: Because a file logger writes the events to disk only when closing the logger or when the number of events in the logger reaches a pre-defined threshold, it cannot be used when debugging processes at run-time. The threaded file logger writes the events to a file after a specified time interval, making it possible to use the logger to visualize progress in real-time, making it useful for debugging.
Use the KnowledgeRuntimeLoggerFactory to add a logger to your session:
KnowledgeRuntimeLogger logger =
    KnowledgeRuntimeLoggerFactory.newFileLogger( ksession, "test" );
// add invocations to the process engine here,
// e.g. ksession.startProcess(processId);
...
logger.close();
Copy to Clipboard Toggle word wrap

Note

When creating a console logger, pass the knowledge session for it as an argument.
The file logger must also be supplied requires the name of the log file to be created.
The threaded file logger requires the interval (in milliseconds) after which the events are to be saved.
You can open the log file in JBDS. To do so, go to the Audit View. Here you will see the events depicted in the form of a tree. (Anything that occurs between the before and after events is shown as a child of that event.)
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2026 Red Hat
Retour au début