Fórum

How to stop Scheduled Job LF6.1

Pablo MMartin, modificado 8 Anos atrás.

How to stop Scheduled Job LF6.1

New Member Postagens: 3 Data de Entrada: 06/11/14 Postagens Recentes
Hi, my problem is that I have a Scheduled job programmatically created in a function and when I want to stop it in other function I can't. I try using SchedulerEngineUtil, MessageBusListener etc and the scheduled job continues working. Only stops when I shutdown the server.

Here is my code:

- Creation of the shceduled job:
String cron = "0 0/1 * 1/1 * ? *";
		    
		 		CronTrigger trigger = null;
				  trigger = new CronTrigger("work1", "grupo1", cron); 
		            
		          SimpleJob job = new SimpleJob();
		          
		          Message message = new Message();
		               
		          try { 

			      			log.info("Arranca el Job");
			      			 //MessageBusUtil.sendMessage(DestinationNames.SCHEDULER_DISPATCH, message);
			      			MessageBusUtil.registerMessageListener(DestinationNames.SCHEDULER_DISPATCH, job);
			  		        SchedulerEngineUtil.schedule(trigger, StorageType.PERSISTED, "Scheduled Job", DestinationNames.SCHEDULER_DISPATCH, message, 0);

		      		
		          } catch (SchedulerException e) { 
		           e.printStackTrace(); 
		          }
		


- Stop function:


SimpleJob job = new SimpleJob();

		
		MessageBusUtil.unregisterMessageListener(DestinationNames.SCHEDULER_DISPATCH, job);
		SchedulerEngineUtil.pause("work1", "grupo1", StorageType.PERSISTED);
		SchedulerEngineUtil.delete("work1", "grupo1", StorageType.PERSISTED);
                SchedulerEngineUtil.unschedule("work1", "grupo1", StorageType.PERSISTED);



Thanks for help.
Regards.
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: How to stop Scheduled Job LF6.1

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Instead of trying to stop the trigger, try stopping the scheduled job "Scheduled Job".
Pablo MMartin, modificado 8 Anos atrás.

RE: How to stop Scheduled Job LF6.1

New Member Postagens: 3 Data de Entrada: 06/11/14 Postagens Recentes
David H Nebinger:
Instead of trying to stop the trigger, try stopping the scheduled job "Scheduled Job".

How can I do that?
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: How to stop Scheduled Job LF6.1

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Okay, my bad I should have reviewed the code first.

So technically your code looks correct. The job would be found by group name and unscheduled.

Are you using the latest GA or do you have something earlier? Have you checked issues.liferay.com?
Pablo MMartin, modificado 8 Anos atrás.

RE: How to stop Scheduled Job LF6.1

New Member Postagens: 3 Data de Entrada: 06/11/14 Postagens Recentes
David H Nebinger:
Okay, my bad I should have reviewed the code first.

So technically your code looks correct. The job would be found by group name and unscheduled.

Are you using the latest GA or do you have something earlier? Have you checked issues.liferay.com?


Hi,

I'm using liferay-portal-6.1.1-ce-ga2

No, I have not checked if are issues, I will check.

Regards.