List of usage examples for org.springframework.integration.support MessageBuilder withPayload
public static <T> MessageBuilder<T> withPayload(T payload)
From source file:org.apilytic.currency.service.impl.DefaultTwitterService.java
/** {@inheritDoc} */ @Override/*w ww .ja v a2s. c o m*/ public boolean isTwitterAdapterRunning() { final MessagingTemplate m = new MessagingTemplate(); final Message<String> operation = MessageBuilder.withPayload("@twitter.isRunning()").build(); @SuppressWarnings("unchecked") Message<Boolean> reply = (Message<Boolean>) m.sendAndReceive(channel, operation); return reply.getPayload(); }
From source file:org.springintegration.service.impl.DefaultTwitterService.java
/** {@inheritDoc} */ @Override// www . j a v a 2s . com public void stopTwitterAdapter() { Message<String> operation = MessageBuilder.withPayload("@twitter.stop()").build(); this.controlBusChannel.send(operation); if (this.dummyTwitter != null) { this.controlBusChannel.send(MessageBuilder.withPayload("@dummyTwitter.stop()").build()); } }
From source file:siia.booking.integration.TripCommandsTest.java
private Message<Leg> createLegMessage(Leg fakeLeg1, int sequenceNumber, int sequenceSize) { return MessageBuilder.withPayload(fakeLeg1).setCorrelationId("wouldBeSetBySplitter") .setSequenceNumber(sequenceNumber).setSequenceSize(sequenceSize).build(); }
From source file:biz.c24.io.spring.integration.transformer.IoUnmarshallingTransformerIUTests.java
@Test public void canUnmarshalXmlFromString() throws Exception { String validString = loadXmlString(); C24UnmarshallingTransformer transformer = new C24UnmarshallingTransformer(model, new XmlSourceFactory()); Message message = MessageBuilder.withPayload(validString).build(); Message<?> outputMessage = transformer.transform(message); assertThat(outputMessage.getPayload(), notNullValue()); assertThat(outputMessage.getPayload(), is(Employees.class)); Employees employees = (Employees) outputMessage.getPayload(); }
From source file:biz.c24.io.spring.integration.transformer.IoMarshallingTransformerIUTests.java
@Test public void canMarshalTextToByteArray() throws Exception { C24MarshallingTransformer ioMarshallingTransformer = new C24MarshallingTransformer(); ioMarshallingTransformer.setOutputType(OutputType.BYTE_ARRAY); ioMarshallingTransformer.setSinkFactory(new TextualSinkFactory()); Message message = MessageBuilder.withPayload(loadObject()).build(); Message<?> outputMessage = ioMarshallingTransformer.transform(message); assertThat((byte[]) outputMessage.getPayload(), is(loadCsvBytes())); }
From source file:siia.booking.integration.FlightNotificationsSpelTest.java
@Test public void notificationShouldArriveAtSmsAdapter() throws Exception { TripNotification notification = mock(TripNotification.class); Message tripNotificationMessage = MessageBuilder.withPayload(notification).build(); CountDownLatch notifierInvoked = new CountDownLatch(1); doAnswer(countsDownLatch(notifierInvoked)).when(smsNotifier).notify(notification); tripNotifications.send(tripNotificationMessage); notifierInvoked.await(100, MILLISECONDS); verify(smsNotifier).notify(notification); }
From source file:org.springintegration.service.impl.DefaultTwitterService.java
@Override public void shutdown() { Message<String> operation = MessageBuilder .withPayload("@integrationMBeanExporter.stopActiveComponents(false, 20000)").build(); if (this.exporter != null) { this.controlBusChannel.send(operation); }//from www . ja va 2s .c o m }
From source file:siia.booking.integration.BookingHeaderTests.java
@Test public void correlationIdHeaderMatches() { Message<?> message = MessageBuilder.withPayload("test").setCorrelationId("ABC-123").build(); assertThat(message, hasCorrelationId("ABC-123")); }
From source file:com.consol.citrus.mail.server.MailServer.java
@Override public boolean accept(String from, String recipient) { if (autoAccept) { return true; }/* w w w. ja va 2 s .c o m*/ org.springframework.integration.Message<?> response = getEndpointAdapter().handleMessage( MessageBuilder.withPayload(mailMessageMapper.toXML(createAcceptRequest(from, recipient))).build()); if (response == null || response.getPayload() == null) { throw new CitrusRuntimeException( "Did not receive accept response. Missing accept response because autoAccept is disabled."); } AcceptResponse acceptResponse = null; if (response.getPayload() instanceof AcceptResponse) { acceptResponse = (AcceptResponse) response.getPayload(); } else if (response.getPayload() instanceof String) { acceptResponse = (AcceptResponse) mailMessageMapper.fromXML(response.getPayload().toString()); } if (acceptResponse == null) { throw new CitrusRuntimeException("Unable to read accept response from paylaod: " + response); } return acceptResponse.isAccept(); }
From source file:biz.c24.io.spring.integration.transformer.IoMarshallingTransformerIUTests.java
@Test public void canMarshalTextToJsonString() throws Exception { C24MarshallingTransformer ioMarshallingTransformer = new C24MarshallingTransformer(); ioMarshallingTransformer.setOutputType(OutputType.STRING); ioMarshallingTransformer.setSinkFactory(new JsonSinkFactory()); Message message = MessageBuilder.withPayload(loadObject()).build(); Message<?> outputMessage = ioMarshallingTransformer.transform(message); String result = ((String) outputMessage.getPayload()).replaceAll("\n", "").replaceAll("\t", ""); String expected = loadJsonString().replaceAll("\n", "").replaceAll("\t", ""); assertThat(result, is(expected));/* w w w . j a v a 2 s.c o m*/ }