List of usage examples for org.springframework.messaging Message getPayload
T getPayload();
From source file:apiserver.services.images.services.jhlabs.GlowFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { GlowJob props = (GlowJob) message.getPayload(); int amount = props.getAmount(); try {// w w w . j av a2s . c om //run filter GlowFilter filter = new GlowFilter(); filter.setAmount(amount); BufferedImage bufferedImage = props.getBufferedImage(); if (bufferedImage == null) { throw new MessageConfigException(MessageConfigException.MISSING_PROPERTY); } BufferedImage outFile = filter.filter(bufferedImage, null); props.setBufferedImage(outFile); return message; } catch (Throwable e) { //log.error(e.getMessage(), e); throw new RuntimeException(e); } }
From source file:apiserver.services.images.services.jhlabs.OilFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { OilJob props = (OilJob) message.getPayload(); int levels = props.getLevels(); int range = props.getRange(); try {// w w w.jav a 2s . com //run filter OilFilter filter = new OilFilter(); filter.setLevels(levels); filter.setRange(range); BufferedImage bufferedImage = props.getBufferedImage(); if (bufferedImage == null) { throw new MessageConfigException(MessageConfigException.MISSING_PROPERTY); } BufferedImage outFile = filter.filter(bufferedImage, null); props.setBufferedImage(outFile); return message; } catch (Exception e) { //log.error(e.getMessage(), e); throw new RuntimeException(e); } }
From source file:biz.c24.io.spring.integration.transformer.XPathTransformerIUTests.java
@Test public void canTransformToString() throws Exception { C24XPathTransformer transformer = new C24XPathTransformer("//Employee[1]/FirstName"); transformer.setEvaluationType(XPathEvaluationType.STRING_RESULT); Message<?> message = MessageBuilder.withPayload(loadObject()).build(); Message<?> outputMessage = transformer.transform(message); assertThat(outputMessage.getPayload(), notNullValue()); assertThat((String) outputMessage.getPayload(), is("Andy")); }
From source file:apiserver.services.images.services.jhlabs.GaussianFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { GaussianJob props = (GaussianJob) message.getPayload(); int radius = props.getRadius(); try {/*from w ww .jav a 2 s . c o m*/ //run filter GaussianFilter filter = new GaussianFilter(radius); BufferedImage bufferedImage = props.getBufferedImage(); if (bufferedImage == null) { throw new MessageConfigException(MessageConfigException.MISSING_PROPERTY); } BufferedImage outFile = filter.filter(bufferedImage, null); props.setBufferedImage(outFile); return message; } catch (Throwable e) { //log.error(e.getMessage(), e); throw new RuntimeException(e); } }
From source file:biz.c24.io.spring.integration.router.XPathRouterTestIUTests.java
@Test public void routesOnString() throws Exception { // Andy/*from w w w.j av a2 s .c o m*/ C24XPathRouter router = new C24XPathRouter("//Employee[1]/FirstName"); router.setChannelResolver(channelResolver); when(channelResolver.resolveDestination("Andy")).thenReturn(messageChannel); ComplexDataObject payload = loadObject(); Message<?> message = MessageBuilder.withPayload(payload).build(); router.handleMessage(message); // Check Message<?> actualMessage = messageChannel.receive(); assertThat((ComplexDataObject) actualMessage.getPayload(), sameInstance(payload)); }
From source file:com.gopivotal.tola.opc.xd.OpcConfigurationTest.java
@Test public void test() { applicationContext.start();/* w w w . j a v a2s. c om*/ Message<?> message = output.receive(10000); assertNotNull(message); assertTrue(message.getPayload() instanceof String); logger.info("message: {}", message); }
From source file:apiserver.services.cache.services.DocumentService.java
public Message<?> getFromCache(Message<?> message) throws MessageConfigException, IOException { Object payload = message.getPayload(); if (!(payload instanceof GetDocumentJob) || ((GetDocumentJob) payload).getDocumentId() == null) { return message; }//from w w w . j a va 2s . co m GetDocumentJob p = (GetDocumentJob) payload; IDocument document = cacheProvider.get(p.getDocumentId()); p.setDocument(document); return message; }
From source file:rest.json.Application.java
@Bean public IntegrationFlow flow() { return IntegrationFlows.from("requestChannel").handle(new GenericHandler<Message>() { @Override// w w w .jav a 2s. com public Object handle(Message payload, Map<String, Object> headers) { System.out.println(payload.getPayload().getClass() + " " + payload.getPayload()); return payload; } }).channel("TestChannel1").transform(new JsonToObjectTransformer(User.class)) .handle(new GenericHandler<Message>() { @Override public Object handle(Message payload, Map<String, Object> headers) { System.out.println( "XXXXXXXXX" + payload.getPayload() + " " + payload.getPayload().getClass()); return payload; } }).get(); }
From source file:apiserver.services.images.services.jhlabs.MaskFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { MaskJob props = (MaskJob) message.getPayload(); Object maskImage = props.getMask(); try {//ww w . j a v a2s . c o m BufferedImage bufferedImage = props.getBufferedImage(); if (bufferedImage == null) { throw new MessageConfigException(MessageConfigException.MISSING_PROPERTY); } BufferedImage destImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), bufferedImage.getType()); //run filter ApplyMaskFilter filter = new ApplyMaskFilter(); filter.setDestination(destImage); filter.setMaskImage(bufferedImage); BufferedImage outFile = filter.filter(bufferedImage, null); props.setBufferedImage(outFile); return message; } catch (Throwable e) { //log.error(e.getMessage(), e); throw new RuntimeException(e); } }
From source file:com.samples.platform.core.SamplesMessageContentProvider.java
/** * @see com.qpark.eip.core.spring.statistics.MessageContentProvider#getNumberOfFailures(org.springframework.messaging.Message) *///from w w w.j a va 2s . com @Override public int getNumberOfFailures(final Message<?> message) { int numberOfFailures = 0; Object payload = message.getPayload(); if (JAXBElement.class.isInstance(payload)) { payload = ((JAXBElement<?>) payload).getValue(); } if (ResponseMessage.class.isInstance(payload)) { numberOfFailures = ((ResponseMessage) payload).getFailure().size(); } return numberOfFailures; }