Foros de discusión

How to stop Scheduled Job LF6.1

Pablo MMartin, modificado hace 8 años.

How to stop Scheduled Job LF6.1

New Member Mensajes: 3 Fecha de incorporación: 6/11/14 Mensajes recientes
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 hace 8 años.

RE: How to stop Scheduled Job LF6.1

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Instead of trying to stop the trigger, try stopping the scheduled job "Scheduled Job".
Pablo MMartin, modificado hace 8 años.

RE: How to stop Scheduled Job LF6.1

New Member Mensajes: 3 Fecha de incorporación: 6/11/14 Mensajes recientes
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 hace 8 años.

RE: How to stop Scheduled Job LF6.1

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
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 hace 8 años.

RE: How to stop Scheduled Job LF6.1

New Member Mensajes: 3 Fecha de incorporación: 6/11/14 Mensajes recientes
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.