List of usage examples for org.springframework.messaging.support MessageBuilder withPayload
public static <T> MessageBuilder<T> withPayload(T payload)
From source file:org.springframework.yarn.support.statemachine.AbstractStateMachine.java
@Override public void sendEvent(E event) { sendEvent(MessageBuilder.withPayload(event).build()); }
From source file:org.springframework.yarn.support.statemachine.ListenerTests.java
@Test public void testStateEvents() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class); assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE)); @SuppressWarnings("unchecked") EnumStateMachine<TestStates, TestEvents> machine = ctx .getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class); TestStateMachineListener listener = new TestStateMachineListener(); machine.addStateListener(listener);//from w w w . java 2 s . c om assertThat(machine, notNullValue()); machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("foo", "jee1").build()); assertThat(listener.states.size(), is(1)); assertThat(listener.states.get(0).from.getId(), is(TestStates.S1)); assertThat(listener.states.get(0).to.getId(), is(TestStates.S2)); machine.sendEvent(MessageBuilder.withPayload(TestEvents.E2).setHeader("foo", "jee2").build()); assertThat(listener.states.size(), is(2)); assertThat(listener.states.get(1).from.getId(), is(TestStates.S2)); assertThat(listener.states.get(1).to.getId(), is(TestStates.S3)); machine.sendEvent(MessageBuilder.withPayload(TestEvents.E4).setHeader("foo", "jee2").build()); assertThat(listener.states.size(), is(2)); ctx.close(); }