code: private void publishEvent(WSJobExecution execution, WSJobInstance jobInstance, BatchStatus batchStatus) {
  
          if (batchStatus == BatchStatus.FAILED) {
              publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_FAILED);
              publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_FAILED);
          } else if (batchStatus == BatchStatus.COMPLETED) {
              publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_COMPLETED);
              publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_COMPLETED);
          } else if (batchStatus == BatchStatus.STOPPED) {
              publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_STOPPED);
              publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_STOPPED);
              //smf call to go here, eventually
          } else if (batchStatus == BatchStatus.STOPPING) {
              publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_STOPPING);
              publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_STOPPING);
          } else if (batchStatus == BatchStatus.STARTED) {
              publishEvent(jobInstance, BatchEventsPublisher.TOPIC_INSTANCE_DISPATCHED);
              publishEvent(execution, BatchEventsPublisher.TOPIC_EXECUTION_STARTED);
          }
  
      }
docs: Helper method to publish execution data to appropriate topic per batchStatus
  
  @param execution
  @param jobInstance
  @param batchStatus