mirror of https://github.com/apache/activemq.git
Ensure proper repeat counts are scheduled.
This commit is contained in:
parent
33dded13df
commit
386210fafe
|
@ -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 {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue