List of usage examples for org.springframework.messaging Message getHeaders
MessageHeaders getHeaders();
From source file:org.springframework.yarn.support.statemachine.AbstractStateMachine.java
private void processEventQueue() { log.debug("Process event queue"); Message<E> queuedEvent = null; while ((queuedEvent = eventQueue.poll()) != null) { Message<E> defer = null;// w ww.j a va 2s.c o m for (Transition<S, E> transition : transitions) { State<S, E> source = transition.getSource(); State<S, E> target = transition.getTarget(); Trigger<S, E> trigger = transition.getTrigger(); if (source.equals(currentState)) { if (trigger != null && trigger.evaluate(queuedEvent.getPayload())) { transition.transit(queuedEvent.getHeaders()); if (transition.getKind() != TransitionKind.INTERNAL) { switchToState(target); } break; } else if (source.getDeferredEvents() != null && source.getDeferredEvents().contains(queuedEvent.getPayload())) { defer = queuedEvent; } } } if (defer != null) { log.info("Deferring event " + defer); deferList.addLast(defer); } } }
From source file:org.springframework.yarn.support.statemachine.AbstractStateMachine.java
private void processDeferList() { log.debug("Process defer list"); ListIterator<Message<E>> iterator = deferList.listIterator(); while (iterator.hasNext()) { Message<E> event = iterator.next(); for (Transition<S, E> transition : transitions) { State<S, E> source = transition.getSource(); State<S, E> target = transition.getTarget(); Trigger<S, E> trigger = transition.getTrigger(); if (source.equals(currentState)) { if (trigger != null && trigger.evaluate(event.getPayload())) { transition.transit(event.getHeaders()); if (transition.getKind() != TransitionKind.INTERNAL) { switchToState(target); }/* www. j a va 2 s . com*/ iterator.remove(); } } } } }