public void initStartDisposeAndLoadSession() {
    try {
      EntityManager em = txm.getEntityManagerFactory().createEntityManager();
      // create new ksession with kstore
      KieSession ksession = kstore.newKieSession(kbase, null, getEnvironment());
      sessionId = ksession.getId();

      logger.info("\n\tSession id: " + sessionId + "\n");

      ksession.getWorkItemManager().registerWorkItemHandler("testWorkItemHandler", workItemHandler);

      ksession.startProcess("timer-flow", null);
      Thread.sleep(4000);
      ksession.dispose();
    } catch (Exception ex) {
      throw new IllegalStateException("The endTheProcess method has been interrupted", ex);
    }
  }
  public void endTheProcess() {
    try {
      KieSession ksession = kstore.loadKieSession(sessionId, kbase, null, getEnvironment());

      // Sleep to check if the timer continues executing.
      logger.info("\n\nSleeping to check that the timer is still running");
      Thread.sleep(5000);

      ksession
          .getWorkItemManager()
          .completeWorkItem(TestWorkItemHandler.getWorkItem().getId(), null);

      logger.info("\n\nSleeping to check that the timer is no longer running");
      Thread.sleep(3000);
      logger.info("Ok");

      ksession.dispose();

    } catch (InterruptedException ex) {
      throw new IllegalStateException("The endTheProcess method has been interrupted", ex);
    }
  }
 public Void execute(Context context) {
   KieSession ksession = ((KnowledgeCommandContext) context).getKieSession();
   ksession.getWorkItemManager().abortWorkItem(workItemId);
   return null;
 }