List of usage examples for org.springframework.messaging Message getPayload
T getPayload();
From source file:org.createnet.raptor.auth.service.services.BrokerMessageHandler.java
public void handle(Message<?> message) { System.out.println(message.getPayload()); JsonNode json;/*from w ww . jav a 2 s. co m*/ try { json = mapper.readTree(message.getPayload().toString()); } catch (IOException ex) { throw new MessagingException("Cannot convert JSON payload: " + message.getPayload().toString()); } switch (json.get("type").asText()) { case "object": User user = userService.getByUuid(json.get("userId").asText()); UserDetails details = new RaptorUserDetailsService.RaptorUserDetails(user); final Authentication authentication = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword(), details.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); SyncRequest req = new SyncRequest(); req.userId = user.getUuid(); req.operation = json.get("op").asText(); req.objectId = json.get("object").get("id").asText(); req.created = json.get("object").get("createdAt").asLong(); deviceService.sync(user, req); SecurityContextHolder.getContext().setAuthentication(null); break; case "data": StreamPayload data = mapper.convertValue(json, StreamPayload.class); break; case "action": ActionPayload action = mapper.convertValue(json, ActionPayload.class); break; case "user": // TODO: Add event notification in auth service break; } }
From source file:apiserver.services.images.services.jhlabs.GrayscaleFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { ImageDocumentJob props = (ImageDocumentJob) message.getPayload(); try {/*from ww w .ja v a2 s.co m*/ // Include filter service GrayscaleFilter filter = new GrayscaleFilter(); 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) { //GrayscaleFilterService.log.error(e.getMessage(), e); throw new RuntimeException(e); } }
From source file:apiserver.services.images.services.jhlabs.MaximumFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { ImageDocumentJob props = (ImageDocumentJob) message.getPayload(); try {//from w w w . j a v a 2 s .c o m //run filter MaximumFilter filter = new MaximumFilter(); 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.MedianFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { ImageDocumentJob props = (ImageDocumentJob) message.getPayload(); try {/*from w ww. j av a 2s .co m*/ //run filter MedianFilter filter = new MedianFilter(); 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.MinimumFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { ImageDocumentJob props = (ImageDocumentJob) message.getPayload(); try {//from www .j ava 2 s .co m //run filter MinimumFilter filter = new MinimumFilter(); 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.BoxBlurFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { BoxBlurJob props = (BoxBlurJob) message.getPayload(); int hRadius = props.getHRadius(); int vRadius = props.getVRadius(); int iterations = props.getIterations(); try {// ww w . ja v a 2 s .c o m //run filter BoxBlurFilter filter = new BoxBlurFilter(hRadius, vRadius, iterations); //filter.setPremultiplyAlpha(((Boolean) props.get("premultiplyAlpha")).booleanValue()); 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.DespeckleFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { ImageDocumentJob props = (ImageDocumentJob) message.getPayload(); //Map headers = (Map) message.getHeaders(); try {/*from w w w.j av a 2 s . c o m*/ //run filter DespeckleFilter filter = new DespeckleFilter(); 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.config.MarshalITests.java
@Test public void canMarshal() throws Exception { template.convertAndSend(loadCsvBytes()); Message<?> message = outputChannel.receive(1); assertThat(message, notNullValue()); assertThat(message.getPayload(), is(byte[].class)); }
From source file:apiserver.services.images.services.jhlabs.LensBlurFilterService.java
public Object doFilter(Message<?> message) throws MessageConfigException { LensBlurJob props = (LensBlurJob) message.getPayload(); float radius = props.getRadius(); int sides = props.getSides(); float bloom = props.getBloom(); try {/*w ww . ja v a 2 s .co m*/ //run filter LensBlurFilter filter = new LensBlurFilter(); filter.setBloom(bloom); filter.setSides(sides); filter.setRadius(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:rest.json.Application.java
@Bean public IntegrationFlow testXChannel1() { return IntegrationFlows.from("TestChannel1").handle(new GenericHandler<Message>() { @Override//from w w w . j a v a2s.c om public Object handle(Message payload, Map<String, Object> headers) { System.out.println("TestChannel1: " + payload.getPayload() + " " + payload.getPayload().getClass()); return payload; } }).channel("TestChannel2").get(); }