掲示板

How to stop Scheduled Job LF6.1

8年前 に Pablo MMartin によって更新されました。

How to stop Scheduled Job LF6.1

New Member 投稿: 3 参加年月日: 14/11/06 最新の投稿
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
8年前 に David H Nebinger によって更新されました。

RE: How to stop Scheduled Job LF6.1

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
Instead of trying to stop the trigger, try stopping the scheduled job "Scheduled Job".
8年前 に Pablo MMartin によって更新されました。

RE: How to stop Scheduled Job LF6.1

New Member 投稿: 3 参加年月日: 14/11/06 最新の投稿
David H Nebinger:
Instead of trying to stop the trigger, try stopping the scheduled job "Scheduled Job".

How can I do that?
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: How to stop Scheduled Job LF6.1

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
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?
8年前 に Pablo MMartin によって更新されました。

RE: How to stop Scheduled Job LF6.1

New Member 投稿: 3 参加年月日: 14/11/06 最新の投稿
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.