/** * Fire the next scheduled <code>Agenda</code> item, skipping items that are not allowed by the * agenda filter. * * @return true if an activation was fired. false if no more activations to fire * @throws org.drools.core.spi.ConsequenceException If an error occurs while firing an agenda * item. */ public int fireNextItem(final AgendaFilter filter, int fireCount, int fireLimit) throws ConsequenceException { boolean tryagain; int localFireCount = 0; try { do { evaluateEagerList(); this.workingMemory.prepareToFireActivation(); tryagain = false; final InternalAgendaGroup group = (InternalAgendaGroup) getNextFocus(); // if there is a group with focus if (group != null) { final AgendaItem item = (AgendaItem) group.remove(); // if there is an item to fire from that group if (item != null) { // if that item is allowed to fire if (filter == null || filter.accept(item)) { // fire it fireActivation(item); localFireCount++; } else { // otherwise cancel it and try the next // necessary to perfom queued actions like signal to a next node in a ruleflow/jbpm // process this.workingMemory.executeQueuedActions(); final EventSupport eventsupport = (EventSupport) this.workingMemory; eventsupport .getAgendaEventSupport() .fireActivationCancelled(item, this.workingMemory, MatchCancelledCause.FILTER); tryagain = true; } } if ((AgendaItem) group.peek() == null || !((AgendaItem) group.peek()).getTerminalNode().isFireDirect()) { // make sure the "fireDirect" meta rules have all impacted first, before unstaging. unstageActivations(); } } } while (tryagain); } finally { this.workingMemory.activationFired(); } return localFireCount; }