Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
    long lastSequenceProcessed = -1;
    String logLabel = "changeLogGshTest";
    try {
      boolean loggerInitted = GrouperLoaderLogger.initializeThreadLocalMap(logLabel);
    
      gsh_builtin_hib3GrouperLoaderLog.appendJobMessage("Starting testIIQChangeLogScript");
      for (EsbEventContainer esbEventContainer : gsh_builtin_esbEventContainers) {
        EsbEvent esbEvent = esbEventContainer.getEsbEvent();
        gsh_builtin_debugMap.put(esbEventContainer.getSequenceNumber() + "_" + esbEvent.getGroupName(), esbEvent.getSourceId() + "_" + esbEvent.getSubjectId());
        gsh_builtin_hib3GrouperLoaderLog.appendJobMessage(esbEventContainer.getSequenceNumber() + "_" + esbEvent.getGroupName() + ", " + esbEvent.getSourceId() + "_" + esbEvent.getSubjectId());
        gsh_builtin_hib3GrouperLoaderLog.addUpdateCount(1);
        lastSequenceProcessed = esbEventContainer.getSequenceNumber();
        GrouperLoaderLogger.addLogEntry(logLabel, "" + esbEventContainer.getSequenceNumber(), esbEvent.getGroupName() + ", " + esbEvent.getSourceId() + "_" + esbEvent.getSubjectId());
      }
    } finally {
      GrouperLoaderLogger.doTheLogging(logLabel);
    }
    return lastSequenceProcessed;


Stopping Daemon Jobs

In Grouper 5.8.1+, it's possible to stop running daemon jobs (that are not stuck).  For example, the job might be in the middle of a lot of changes that are being processed and you'd like to stop it.  To allow this functionality with your job, you would need to add the following line of code to various places in your script.  For example, you may add it within a loop or after some amount of work is done.

Code Block
GrouperDaemonUtils.stopProcessingIfJobPaused();


Normally, this line of code executes very quickly and doesn't do anything.  But if a Grouper Admin goes into the Daemon Jobs page in the Grouper UI and disables your job, after a few seconds (~10s), the Grouper Daemon engine will realize that the job has been disabled.  After that, the next time your script executes the line of code above, it will throw a RuntimeException.  So assuming your script doesn't catch the exception, the job will then end.