/** * Method factory for creating a cron trigger * * @return jobDetail * @throws java.text.ParseException */ protected Trigger getBusinessTrigger(TriggerBuilder triggerBuilder) throws ParseException { CronScheduleBuilder cronScheduleBuilder = cronSchedule(this.consumerConfiguration.getCronExpression()); if (this.consumerConfiguration.isIgnoreMisfire()) { cronScheduleBuilder.withMisfireHandlingInstructionDoNothing(); } if (this.consumerConfiguration.getTimezone() != null && this.consumerConfiguration.getTimezone().length() > 0) { cronScheduleBuilder.inTimeZone(TimeZone.getTimeZone(this.consumerConfiguration.getTimezone())); } // start the business schedule 1 second in the future to ensure we // do not immediately callback on submission to quartz triggerBuilder.withSchedule(cronScheduleBuilder) .startAt(new Date(System.currentTimeMillis() + 1000)); return triggerBuilder.build(); }
/** * Logic to determine how to manage the eager trigger schedule. * @param trigger * @throws SchedulerException */ protected void invokeEagerSchedule(Trigger trigger) throws SchedulerException { Integer eagerCallbacks = (Integer)trigger.getJobDataMap().get(EAGER_CALLBACK_COUNT); if(eagerCallbacks == null) { eagerCallbacks = new Integer(0); } // if data available and maxEagerCallbacks is not set or less than max if ((consumerConfiguration.getMaxEagerCallbacks() == 0 || eagerCallbacks < consumerConfiguration.getMaxEagerCallbacks()) ) { // schedule the eager trigger scheduleAsEagerTrigger(trigger, ++eagerCallbacks); } else { scheduleAsBusinessTrigger(trigger); } }
/** * Setup the flow expectations, make sure that testHarness listener is attached to flow and start the given flow. * */ public void startFlow() { flowTestHarness = new FlowTestHarnessImpl(flowExpectations); testHarnessFlowEventListener.removeAllObservers(); testHarnessFlowEventListener.addObserver((FlowObserver) flowTestHarness); testHarnessFlowEventListener.setIgnoreEventCapture(true); if (this.scheduledConsumerName != null) { Object component = getComponent(scheduledConsumerName); ScheduledConsumerConfiguration configuration = ((ScheduledConsumer) component).getConfiguration(); configuration.setCronExpression("0/5 * * * * ? 2099"); // set to never run configuration.setEager(false); // do not callback on the provider once complete } flow.setFlowListener(testHarnessFlowEventListener); flow.start(); Assert.assertEquals("flow should be running", "running", flow.getState()); }
/** * Setup the flow expectations and start the given flow. * */ public void startFlow() { flowTestHarness = new FlowTestHarnessImpl(flowExpectations); testHarnessFlowEventListener.removeAllObservers(); testHarnessFlowEventListener.addObserver((FlowObserver) flowTestHarness); testHarnessFlowEventListener.setIgnoreEventCapture(true); if (this.scheduledConsumerName != null) { Object component = getComponent(scheduledConsumerName); ScheduledConsumerConfiguration configuration = ((ScheduledConsumer) component).getConfiguration(); configuration.setCronExpression("0/5 * * * * ? 2099"); // set to never run configuration.setEager(false); // do not callback on the provider once complete } flow.setFlowListener(testHarnessFlowEventListener); flow.start(); Assert.assertEquals("flow should be running", "running", flow.getState()); }
/** * Setup the flow expectations and start the given flow. * * @param testHarnessFlowEventListener the test harness flow listener */ public void startFlow(FlowSubject testHarnessFlowEventListener) { flowTestHarness = new FlowTestHarnessImpl(flowExpectations); testHarnessFlowEventListener.removeAllObservers(); testHarnessFlowEventListener.addObserver((FlowObserver) flowTestHarness); testHarnessFlowEventListener.setIgnoreEventCapture(true); if (this.scheduledConsumerName != null) { FlowElement<?> flowElement = flow.getFlowElement(scheduledConsumerName); ScheduledConsumerConfiguration configuration = ((ScheduledConsumer) flowElement.getFlowComponent()).getConfiguration(); configuration.setCronExpression("0/5 * * * * ? 2099"); // set to never run configuration.setEager(false); // do not callback on the provider once complete } flow.start(); Assert.assertEquals("flow should be running", "running", flow.getState()); }