Example usage for org.springframework.messaging Message getPayload

List of usage examples for org.springframework.messaging Message getPayload

Introduction

In this page you can find the example usage for org.springframework.messaging Message getPayload.

Prototype

T getPayload();

Source Link

Document

Return the message payload.

Usage

From source file:apiserver.services.pdf.service.MergePdfFilesCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    ExtractImageResult props = (ExtractImageResult) message.getPayload();

    try {//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<CollectionResult> future = exec
                .submit(new MergePdfCallable(props.getFile().getFileBytes(), props.getOptions()));

        CollectionResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getCollection());

        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:apiserver.services.pdf.service.RemotePdfWatermarkCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    WatermarkPdfResult props = (WatermarkPdfResult) message.getPayload();

    try {// w  w w  .  jav a2s.com
        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 RemoveWatermarkCallable(props.getFile().getFileBytes(), props.getOptions()));

        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:apiserver.services.pdf.service.TransformPdfCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    TransformPdfResult props = (TransformPdfResult) message.getPayload();

    try {/*from  w  ww . ja va  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 TransformPdfCallable(props.getFile().getFileBytes(), props.getOptions()));

        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.transformer.XPathTransformerIUTests.java

@Test
public void canTransformToListOfEmployee() throws Exception {

    C24XPathTransformer transformer = new C24XPathTransformer("//Employee");
    transformer.setEvaluationType(XPathEvaluationType.LIST_RESULT);

    Message<?> message = MessageBuilder.withPayload(loadObject()).build();

    Message<?> outputMessage = transformer.transform(message);

    List<Object> payload = (List<Object>) outputMessage.getPayload();
    assertThat(payload, notNullValue());
    for (Object o : payload) {
        assertThat(o, is(Employee.class));
    }/* w  w w. j a v  a 2s . c o m*/
}

From source file:apiserver.services.pdf.service.ExtractPdfFormFieldsCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    ExtractPdfFormResult props = (ExtractPdfFormResult) message.getPayload();

    try {//from   w  ww.  j  av a2s .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<MapResult> future = exec.submit(new ExtractFormFieldsCallable(props.getFile().getFileBytes()));

        MapResult _result = future.get(defaultTimeout, TimeUnit.SECONDS);
        props.setResult(_result.getData());

        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:apiserver.services.pdf.service.ProtectPdfCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    SecurePdfResult props = (SecurePdfResult) message.getPayload();
    File tmpFile = null;/*ww w.  j ava 2 s  .co m*/

    try {
        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 ProtectPdfCallable(props.getFile().getFileBytes(), props.getOptions()));

        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);
    } finally {
        if (tmpFile != null)
            tmpFile.delete();
    }
}

From source file:apiserver.services.pdf.service.DeletePdfPagesCFService.java

public Object execute(Message<?> message) throws ColdFusionException {
    DeletePdfPagesResult props = (DeletePdfPagesResult) message.getPayload();

    try {//w w  w .  j  a va2  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 DeletePagesCallable(props.getFile().getFileBytes(), props.getOptions()));

        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:simple.flow.Application.java

@Bean
public IntegrationFlow flow() {
    return IntegrationFlows.from("requestChannel1").handle(new GenericHandler<Message>() {
        @Override/*from w w  w  .ja  v a 2 s.com*/
        public Object handle(Message payload, Map<String, Object> headers) {
            System.out
                    .println("requestChannel1 " + payload.getPayload().getClass() + " " + payload.getPayload());
            return payload;
        }
    }).get();
}

From source file:simple.flow.Application.java

@Bean
public IntegrationFlow errorFlow() {
    return IntegrationFlows.from("requestChannel2").handle(new GenericHandler<Message>() {
        @Override/*  w w w .  ja  v  a  2  s.  c om*/
        public Object handle(Message payload, Map<String, Object> headers) {
            System.out
                    .println("requestChannel2 " + payload.getPayload().getClass() + " " + payload.getPayload());
            return payload;
        }
    }).get();
}

From source file:biz.c24.io.spring.integration.transformer.IoTransformerIUTests.java

@Test
public void canTransform() throws Exception {

    C24Transformer transformer = new C24Transformer();
    transformer.setTransformClass(ExampleTransform.class);

    Message<?> message = MessageBuilder.withPayload(loadObject()).build();

    Message<?> outputMessage = transformer.transform(message);

    assertThat(outputMessage.getPayload(), notNullValue());
    assertThat(outputMessage.getPayload(), is(OutputDocumentRoot.class));

}