this.invoke(t); if(this.getConfiguration().isEager() && t != null) invokeEagerSchedule(context.getTrigger()); scheduleAsBusinessTrigger(context.getTrigger()); if(this.getConfiguration().isEager()) invokeEagerSchedule(context.getTrigger()); else if(isEagerCallback(context.getTrigger())) scheduleAsBusinessTrigger(context.getTrigger());
/** * 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); } }
/** * Invoke the eventListener with the incoming mes * @param message the message */ public void invoke(T message) { if (message != null) { FlowEvent<?, ?> flowEvent = createFlowEvent(message); this.eventListener.invoke(flowEvent); } else { if(logger.isDebugEnabled()) { logger.debug("'null' returned from MessageProvider. Flow not invoked"); } } }
/** * Start the underlying tech */ public void start() { try { JobKey jobkey = jobDetail.getKey(); TriggerBuilder triggerBuilder = newTriggerFor(jobkey.getName(), jobkey.getGroup()); Trigger trigger = getBusinessTrigger(triggerBuilder); Date scheduledDate = scheduler.scheduleJob(jobDetail, trigger); logger.info("Scheduled consumer for flow [" + jobkey.getName() + "] module [" + jobkey.getGroup() + "] starting at [" + scheduledDate + "]"); } catch (SchedulerException | ParseException e) { throw new RuntimeException(e); } }
/** * 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()); }
/** * Invoke the scheduled consumer via its triggerSchedulerNow method * <p> * This method executes the underlying Job asynchronously */ public void fireScheduledConsumer() { ScheduledConsumer consumer = (ScheduledConsumer) getComponent(scheduledConsumerName); try { JobDetail jobDetail = ((ScheduledComponent<JobDetail>)consumer).getJobDetail(); Trigger trigger = newTrigger().withIdentity("name", "group").forJob(jobDetail).build(); consumer.scheduleAsEagerTrigger(trigger, 0); } catch (SchedulerException se) { throw new RuntimeException(se); } }
Trigger newTrigger = getBusinessTrigger(oldTrigger.getTriggerBuilder()); newTrigger.getJobDataMap().clear(); if(this.isRunning())
/** * Invoke the scheduled consumer with a given JobExecutionContext (can be mocked). * * This method executes synchronously - when the flow finished executing the given task this method will then return. * * @param jobExecutionContext a JobExecutionContext */ public void fireScheduledConsumerSynchronously(JobExecutionContext jobExecutionContext) { ScheduledConsumer consumer = (ScheduledConsumer) getComponent(scheduledConsumerName); consumer.execute(jobExecutionContext); }
/** * 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()); }
/** * Invoke the scheduled consumer via its triggerSchedulerNow method * <p> * This method executes the underlying Job asynchronously */ public void fireScheduledConsumer() { ScheduledConsumer consumer = (ScheduledConsumer) getComponent(scheduledConsumerName); try { JobDetail jobDetail = ((ScheduledComponent<JobDetail>)consumer).getJobDetail(); Trigger trigger = newTrigger().withIdentity("name", "group").forJob(jobDetail).build(); consumer.scheduleAsEagerTrigger(trigger, 0); } catch (SchedulerException se) { throw new RuntimeException(se); } }
/** * Invoke the scheduled consumer with a given JobExecutionContext (can be mocked). * * This method executes synchronously - when the flow finished executing the given task this method will then return. * * @param jobExecutionContext a JobExecutionContext */ public void fireScheduledConsumerSynchronously(JobExecutionContext jobExecutionContext) { ScheduledConsumer consumer = (ScheduledConsumer) getComponent(scheduledConsumerName); consumer.execute(jobExecutionContext); }
/** * 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()); }
@Override public void onResubmission(T event) { if (event != null) { FlowEvent<?, ?> flowEvent = createFlowEvent(event); Resubmission resubmission = this.resubmissionEventFactory.newResubmissionEvent(flowEvent); this.eventListener.invoke(resubmission); } else { if(logger.isDebugEnabled()) { logger.debug("'null' value resubmitted. Flow not invoked"); } } }