List of usage examples for org.springframework.messaging Message getPayload
T getPayload();
From source file:com.consol.citrus.samples.greeting.GreetingService.java
@Override public Message<GreetingResponseMessage> processMessage(Message<GreetingRequestMessage> request) { GreetingResponseMessage response = new GreetingResponseMessage(); response.setOperation(request.getPayload().getOperation()); response.setCorrelationId(request.getPayload().getCorrelationId()); response.setUser("GreetingService"); response.setText("Hello " + request.getPayload().getUser() + "!"); MessageBuilder<GreetingResponseMessage> builder = MessageBuilder.withPayload(response); builder.setHeader("CorrelationId", request.getHeaders().get("CorrelationId")); builder.setHeader("Operation", "sayHello"); builder.setHeader("Type", "response"); return builder.build(); }
From source file:org.opencredo.couchdb.transformer.CouchDbIdToDocumentTransformerTest.java
@Test public void transformStringMessage() throws Exception { String uuid = UUID.randomUUID().toString(); DummyDocument document = new DummyDocument("test"); when(documentOperations.readDocument(eq(uuid), eq(DummyDocument.class))).thenReturn(document); Message<String> message = MessageBuilder.withPayload(uuid).build(); Message<DummyDocument> transformedMessage = (Message<DummyDocument>) transformer.transform(message); assertThat(transformedMessage.getPayload(), equalTo(document)); }
From source file:org.opencredo.couchdb.transformer.CouchDbIdToDocumentTransformerTest.java
@Test public void transformUuidMessage() throws Exception { UUID uuid = UUID.randomUUID(); DummyDocument document = new DummyDocument("test"); when(documentOperations.readDocument(eq(uuid.toString()), eq(DummyDocument.class))).thenReturn(document); Message<UUID> message = MessageBuilder.withPayload(uuid).build(); Message<DummyDocument> transformedMessage = (Message<DummyDocument>) transformer.transform(message); assertThat(transformedMessage.getPayload(), equalTo(document)); }
From source file:org.opencredo.couchdb.transformer.CouchDbUrlToDocumentTransformerTest.java
@Test public void transformUriMessage() throws Exception { URI uri = new URI("http://test"); DummyDocument document = new DummyDocument("test"); when(documentOperations.readDocument(eq(uri), eq(DummyDocument.class))).thenReturn(document); Message<URI> message = MessageBuilder.withPayload(uri).build(); Message<DummyDocument> transformedMessage = (Message<DummyDocument>) transformer.transform(message); assertThat(transformedMessage.getPayload(), equalTo(document)); }
From source file:org.opencredo.couchdb.transformer.CouchDbUrlToDocumentTransformerTest.java
@Test public void transformStringMessage() throws Exception { String uri = "http://test"; DummyDocument document = new DummyDocument("test"); when(documentOperations.readDocument(eq(new URI(uri)), eq(DummyDocument.class))).thenReturn(document); Message<String> message = MessageBuilder.withPayload(uri).build(); Message<DummyDocument> transformedMessage = (Message<DummyDocument>) transformer.transform(message); assertThat(transformedMessage.getPayload(), equalTo(document)); }
From source file:apiserver.services.images.services.coldfusion.ImageResizeCFService.java
public Object execute(Message<?> message) throws ColdFusionException { FileResizeJob props = (FileResizeJob) message.getPayload(); try {/*from w ww . j a v a 2s .c o m*/ cfcPath = imageConfigMBean.getImageResizePath(); String method = imageConfigMBean.getImageResizeMethod(); String arguments = ""; // extract properties Map<String, Object> methodArgs = props.toMap(); // execute Object cfcResult = coldFusionBridge.invoke(cfcPath, method, methodArgs); if (cfcResult instanceof byte[]) { // convert base64 back to buffered image byte[] bytes = Base64.decodeBase64(new String((byte[]) cfcResult)); BufferedImage bi = ImageIO.read(new ByteArrayInputStream(bytes)); props.setBufferedImage(bi); } else { throw new NotImplementedException(); } return props; } catch (Throwable e) { e.printStackTrace(); //todo use logging library throw new RuntimeException(e); } finally { } }
From source file:apiserver.services.pdf.service.PopulatePdfFormFieldsCFService.java
public Object execute(Message<?> message) throws ColdFusionException { PopulatePdfFormResult props = (PopulatePdfFormResult) message.getPayload(); try {/*from w w w. j a v a 2 s . c o m*/ long startTime = System.nanoTime(); Grid grid = verifyGridConnection(); // Get grid-enabled executor service for nodes where attribute 'worker' is defined. ExecutorService exec = getColdFusionExecutor(); Future<ByteArrayResult> future = exec .submit(new PopulateFormFieldsCallable(props.getFile().getFileBytes(), props.getFields(), ((String) props.getOptions().get("password")))); ByteArrayResult _result = future.get(defaultTimeout, TimeUnit.SECONDS); props.setResult(_result.getBytes()); long endTime = System.nanoTime(); log.debug("execution times: CF=" + _result.getStats().getExecutionTime() + "ms -- total=" + (endTime - startTime) + "ms"); return props; } catch (Exception ge) { throw new RuntimeException(ge); } }
From source file:biz.c24.io.spring.integration.config.FileSplitterTests.java
@Test public void splitFileInTwo() throws Exception { transformer.setBatchSize(5);//w w w. j av a2s .c o m Boolean result = (Boolean) transformer .doTransform(MessageBuilder.withPayload((resource.getFile())).build()); Message<List<String>> message = (Message<List<String>>) feedChannel.receive(); assertThat(message.getPayload(), is(not(nullValue()))); assertThat(message.getPayload().get(0), is("1")); assertThat(message.getPayload().get(4), is("5")); message = (Message<List<String>>) feedChannel.receive(); assertThat(message.getPayload(), is(not(nullValue()))); assertThat(message.getPayload().get(0), is("6")); assertThat(message.getPayload().get(4), is("10")); assertThat(result, is(true)); }
From source file:biz.c24.io.spring.integration.selector.C24ValidatingMessageSelector.java
public boolean accept(Message<?> message) { Object payload = message.getPayload(); ComplexDataObject cdo;// w ww. j a v a2 s . co m try { cdo = (ComplexDataObject) payload; } catch (ClassCastException e) { throw new MessagingException("Cannot validate payload of type [" + payload.getClass().getName() + "]. Only ComplexDataObject is supported.", e); } boolean result; if (!throwExceptionOnRejection || failFast) { result = validateFailFast(cdo, message); } else { result = validateAllEvents(cdo); } return result; }
From source file:rest.json.Application.java
@Bean public IntegrationFlow testXChannel3() { return f -> f.handle(new GenericHandler<Message>() { @Override/*from w w w . j a v a 2s . c o m*/ public Object handle(Message payload, Map<String, Object> headers) { System.out .println("testXChannel3: " + payload.getPayload() + " " + payload.getPayload().getClass()); return payload; } }); }