<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "How to ignore the paused (old) jobs..????"]]></title>
		<link>http://forums.terracotta.org/forums/posts/list/17.page</link>
		<description><![CDATA[Latest messages posted in the topic "How to ignore the paused (old) jobs..????"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ Hi.,

I have a job which runs on every monday,tuesday,friday. I'm using cron triggers. 

But if i pause the job on sunday and resume the same job on thursday, i could see that the old jobs (monday's and tuesday's jobs) have been triggered at the moment when i resume job on thursday. but the old jobs should have not been triggered , only the upcoming jobs should get triggered.

How can i ignore the old jobs getting run..?? 

I have tried with the following scenarios.

1) nextFireTime = cronTrigger.getFireTimeAfter(null);
    cronTrigger.setNextFireTime(nextFireTime);

2)cronTrigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);

3) cronTrigger.updateAfterMisfire(null);

But nothing works fine for me. :( Please help me in proving a solution on the above problem


Thanks
SK Raana (Thalaivar SuperStar's Fanatic)
]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35326</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35326</link>
				<pubDate><![CDATA[Sun, 10 Jun 2012 22:28:21]]> GMT</pubDate>
				<author><![CDATA[ skraana]]></author>
			</item>
			<item>
				<title>Re:How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ Hello ,
The scenario 2, cronTrigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);  should have been enough (the documentation states :
<span class="genmed"><b>Code:</b></span><br>
		<div>
		<pre bbCodeId="pre-code" style="overflow: auto; width: 95%; max-height: 350px; height:expression(this.scrollHeight > 350 ? '350px' : 'auto');">
    /**
     * &lt;p&gt;
     * Instructs the &lt;code&gt;{@link Scheduler}&lt;/code&gt; that upon a mis-fire
     * situation, the &lt;code&gt;{@link CronTrigger}&lt;/code&gt; wants to have it's
     * next-fire-time updated to the next time in the schedule after the current
     * time &#40;taking into account any associated &lt;code&gt;{@link Calendar}&lt;/code&gt;,
     * but it does not want to be fired now.
     * &lt;/p&gt;
     */
    public static final int MISFIRE_INSTRUCTION_DO_NOTHING = 2;
</pre>
		</div>

could you please share more details such as the initialization code/ quartz.properties / logs / quartz version , that can reproduce the problem ?]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35332</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35332</link>
				<pubDate><![CDATA[Mon, 11 Jun 2012 04:52:14]]> GMT</pubDate>
				<author><![CDATA[ adahanne]]></author>
			</item>
			<item>
				<title>Re:How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ Hello..,

This is wat my code..,

and i'm using this jar : quartz-all-1.5.2.jar


cronTrigger =
(CronTrigger)scheduler.getTrigger(JOB_NAME, JOB_GROUP_NAME);
Date nextFireTime = cronTrigger.getNextFireTime();
if ((nextFireTime.getTime()) < System.currentTimeMillis()) {
nextFireTime = cronTrigger.getFireTimeAfter(null);
if (nextFireTime == null){							 scheduler.deleteJob(JOB_NAME,JOB_GROUP_NAME);
}else{					cronTrigger.setNextFireTime(nextFireTime);
cronTrigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
cronTrigger.updateAfterMisfire(null);
scheduler.resumeJob(JOB_NAME ,JOB_GROUP_NAME);
}
}

Here i have tried with all possible scenarios., but nothing turned up. :( 

My logic is that., if the next fire time of my job is lesser than the current time then im trying to update the next fire time with the new time which is greater than the current date.

if my next fire time is null which means the job has reached the end time, then im deleting that job. so that the status will be completed.

but even though im updating the next fire time with the new date.., it runs all the paused old jobs., it should have not been run. pls help me on this problem.., 


Thanks
SK Raana
]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35344</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35344</link>
				<pubDate><![CDATA[Mon, 11 Jun 2012 21:38:21]]> GMT</pubDate>
				<author><![CDATA[ skraana]]></author>
			</item>
			<item>
				<title>Re:How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ Hello,
I was rather mentioning the code that creates/ initializes your cronTrigger (the code you sent just shows that you are trying to handle manually misfires; I'm pretty sure you don't need to do that)
could you attach a simple test case, to reproduce your misfire behaviour ? You could attach your java code + your quartz.properties.
Thanks
]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35345</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35345</link>
				<pubDate><![CDATA[Tue, 12 Jun 2012 05:27:45]]> GMT</pubDate>
				<author><![CDATA[ adahanne]]></author>
			</item>
			<item>
				<title>Re:How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ Hello..,


public class MyCronTrigger extends CronTrigger {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public MyCronTrigger(String jobName,String gruopName,String cronExpression) throws ParseException{
		super(jobName,gruopName,cronExpression);
	}
	
	@Override
    public Date getNextFireTime() {
        Date nextFireTime = super.getNextFireTime();
        if (nextFireTime.getTime() < System.currentTimeMillis()) {
            nextFireTime = super.getFireTimeAfter(null);
            super.setNextFireTime(nextFireTime);
        }
        return nextFireTime;
    }
	
}



			SchedulerFactory schedulerFactory = new StdSchedulerFactory();
			Scheduler scheduler = schedulerFactory.getScheduler();
			JobDetail jobDetail = new JobDetail(JOB_NAME,JOB_GROUP_NAME, MyJob.class);
			CronTrigger cronTrigger = new MyCronTrigger(JOB_NAME ,JOB_GROUP_NAME, cronExpression);
				cronTrigger.setStartTime(startDate);
cronTrigger.setEndTime(endDate);
scheduler.scheduleJob(jobDetail, cronTrigger);
			scheduler.start();


This is how im creating my job.

For pausing my job i have used the below logic 

cronTrigger =
(CronTrigger)scheduler.getTrigger(JOB_NAME, JOB_GROUP_NAME);
Date nextFireTime = cronTrigger.getNextFireTime();
if ((nextFireTime.getTime()) < System.currentTimeMillis()) {
nextFireTime = cronTrigger.getFireTimeAfter(null);
if (nextFireTime == null){ scheduler.deleteJob(JOB_NAME,JOB_GROUP_NAME);
}else{ cronTrigger.setNextFireTime(nextFireTime);
cronTrigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
cronTrigger.updateAfterMisfire(null);
scheduler.resumeJob(JOB_NAME ,JOB_GROUP_NAME);
}
} 

pls help me to give a solution for this problem


Thanks 
SK Raana]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35346</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35346</link>
				<pubDate><![CDATA[Tue, 12 Jun 2012 05:35:08]]> GMT</pubDate>
				<author><![CDATA[ skraana]]></author>
			</item>
			<item>
				<title>Re:How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ why didnt you use :
CronTrigger trigger = newTrigger().withIdentity("trigger1", "group1")               .withSchedule(cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing()).build();
to create your trigger in the first place ? You would not need all the code you wrote after.
btw, when you do your update operations on the trigger, you are working with a clone of the trigger; so you would need to re schedule your trigger after updates]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35348</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35348</link>
				<pubDate><![CDATA[Tue, 12 Jun 2012 07:11:50]]> GMT</pubDate>
				<author><![CDATA[ adahanne]]></author>
			</item>
			<item>
				<title>Re:How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ Hello adahanne..

cronTrigger = newTrigger().withIdentity(CannedReportingMailJob.JOB_NAME , ScheduleReportJobConstants.JOB_GROUP_NAME) .withSchedule(cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing()).build();

THis line contains the compile error "The method newTrigger() is undefined for the type MyClass". i tried to import the following package 

import static org.quartz.JobBuilder.*;

but i could not resolve the compilation issues.., thar import line itself contains the compilation error as "The import org.quartz.JobBuilder cannot be resolved" 

I'm using this jar : quartz-all-1.5.2.jar 

I'm new to this quartz., pls assist me in this.

Thanks
SK Raana]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35356</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35356</link>
				<pubDate><![CDATA[Tue, 12 Jun 2012 22:57:14]]> GMT</pubDate>
				<author><![CDATA[ skraana]]></author>
			</item>
			<item>
				<title>Re:How to ignore the paused (old) jobs..????</title>
				<description><![CDATA[ right, I provided an example with the quartz builder API, that actually appeared in quartz 2.0 : http://quartz-scheduler.org/documentation/quartz-2.x/new-in-quartz-2
 whether you can switch to a more modern version or quartz, or you can use the old style : http://quartz-scheduler.org/documentation/quartz-1.x/examples/Example5]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/7094.page#35364</guid>
				<link>http://forums.terracotta.org/forums/posts/list/7094.page#35364</link>
				<pubDate><![CDATA[Wed, 13 Jun 2012 07:06:33]]> GMT</pubDate>
				<author><![CDATA[ adahanne]]></author>
			</item>
	</channel>
</rss>