title: How to stop or pause a scheduled job in Liferay 6.1
body: <p>I have a portlet that launches a <em>scheduled job</em>. But when I try to pause or stop it, the job continues executing. I don't know if I'm doing something wrong when creating the scheduled job or when I'm trying to stop/pause it.</p>
  
  <p>Here is how I launch the job:</p>
  
  <pre><code>CronTrigger trigger = new CronTrigger("job1", "group1", "0 0/1 * 1/1 * ? *");
  
  SimpleJob job = new SimpleJob();
  MessageBusUtil.registerMessageListener(DestinationNames.SCHEDULER_DISPATCH, job);
  
  Message message = new Message();
  message.put(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME, SimpleJob.class.getName());
  SchedulerEngineUtil.schedule(trigger, StorageType.PERSISTED, 
      "Scheduled Job", DestinationNames.SCHEDULER_DISPATCH, message, 0);
  </code></pre>
  
  <p>Here is the job:</p>
  
  <pre><code>public class SimpleJob implements  MessageListener {
      private static Log log = LogFactoryUtil.getLog(SimpleJob.class);
  
      @Override
      public void receive(Message message) throws MessageListenerException {
          log.debug(" ... SimpleJob executed ... ");      
      }
  
  }
  </code></pre>
  
  <p>And here is the function that tries to stop:</p>
  
  <pre><code>public void stopCron(ActionRequest request, ActionResponse response)throws Exception{
      SimpleJob job = new SimpleJob();
  
      MessageBusUtil.unregisterMessageListener(DestinationNames.SCHEDULER_DISPATCH, job);
      SchedulerEngineUtil.pause("job1", "group1", StorageType.PERSISTED);
      SchedulerEngineUtil.delete("job1", "group1", StorageType.PERSISTED);
      SchedulerEngineUtil.unschedule("job1", "group1", StorageType.PERSISTED);
  
  }
  </code></pre>
  
  <p>How can I stop the job?</p>