Ensure proper repeat counts are scheduled.
(cherry picked from commit 386210fafe)
This commit is contained in:
Timothy Bish 2016-02-04 17:16:33 -05:00
parent 23e9ecaec1
commit 4782feb6a1
2 changed files with 11 additions and 4 deletions

View File

@ -273,7 +273,9 @@ public class InMemoryJobScheduler implements JobScheduler {
private void doReschedule(InMemoryJob job, long nextExecutionTime) {
job.setNextTime(nextExecutionTime);
job.incrementExecutionCount();
job.decrementRepeatCount();
if (!job.isCron()) {
job.decrementRepeatCount();
}
LOG.trace("JobScheduler rescheduling job[{}] to fire at: {}", job.getJobId(), JobSupport.getDateTime(nextExecutionTime));
@ -291,7 +293,6 @@ public class InMemoryJobScheduler implements JobScheduler {
} finally {
lock.writeLock().unlock();
}
}
private void doRemoveJob(String jobId) throws IOException {

View File

@ -38,9 +38,13 @@ import org.apache.activemq.ScheduledMessage;
import org.apache.activemq.util.ProducerThread;
import org.apache.activemq.util.Wait;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JmsSchedulerTest extends JobSchedulerTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(JmsSchedulerTest.class);
@Test
public void testCron() throws Exception {
final int COUNT = 10;
@ -55,8 +59,9 @@ public class JmsSchedulerTest extends JobSchedulerTestSupport {
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
count.incrementAndGet();
latch.countDown();
LOG.info("Received scheduled message, waiting for {} more", latch.getCount());
}
});
@ -167,8 +172,9 @@ public class JmsSchedulerTest extends JobSchedulerTestSupport {
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
latch.countDown();
count.incrementAndGet();
latch.countDown();
LOG.info("Received scheduled message, waiting for {} more", latch.getCount());
}
});