Java 类org.apache.camel.converter.jaxb.JaxbDataFormat 实例源码

项目:Camel    文件:JmsJaxbTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(deadLetterChannel("jms:queue:error").redeliveryDelay(0));

            onException(InvalidOrderException.class).maximumRedeliveries(0).handled(true)
                .to("jms:queue:invalid");

            DataFormat jaxb = new JaxbDataFormat("org.apache.camel.itest.jms");

            from("jms:queue:in")
                .unmarshal(jaxb)
                .choice()
                    .when().method(JmsJaxbTest.class, "isWine").to("jms:queue:wine")
                    .otherwise().throwException(new InvalidOrderException("We only like wine"))
                .end();

            from("jms:queue:wine").to("mock:wine");
            from("jms:queue:error").to("mock:error");
            from("jms:queue:invalid").to("mock:invalid");
        }
    };
}
项目:Camel    文件:JaxbDataFormatAutoConfiguration.java   
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JaxbDataFormat.class)
public JaxbDataFormat configureJaxbDataFormat(CamelContext camelContext,
        JaxbDataFormatConfiguration configuration) throws Exception {
    JaxbDataFormat dataformat = new JaxbDataFormat();
    if (dataformat instanceof CamelContextAware) {
        ((CamelContextAware) dataformat).setCamelContext(camelContext);
    }
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    IntrospectionSupport.setProperties(camelContext,
            camelContext.getTypeConverter(), dataformat, parameters);
    return dataformat;
}
项目:Camel    文件:DataFormatTest.java   
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {

            JaxbDataFormat example = new JaxbDataFormat("org.apache.camel.example");
            JaxbDataFormat person = new JaxbDataFormat("org.apache.camel.foo.bar");
            person.setPrettyPrint(true);

            from("direct:start").
                    marshal(example).
                    to("direct:marshalled");

            from("direct:marshalled").
                    unmarshal().jaxb("org.apache.camel.example").
                    to("mock:result");

            from("direct:prettyPrint").
                    marshal(person).
                    to("mock:result");
        }
    };
}
项目:Camel    文件:DataFormatConcurrentTest.java   
@Test
public void testUnmarshalConcurrent() throws Exception {
    template.setDefaultEndpointUri("direct:unmarshal");
    final CountDownLatch latch = new CountDownLatch(warmupCount + testCycleCount);

    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:unmarshal")
                    .unmarshal(new JaxbDataFormat("org.apache.camel.example"))
                    .process(new Processor() {
                        @Override
                        public void process(Exchange exchange) throws Exception {
                            latch.countDown();
                        }
                    });
        }
    });

    unmarshal(latch);
}
项目:Camel    文件:DataFormatConcurrentTest.java   
@Test
public void testMarshallConcurrent() throws Exception {
    template.setDefaultEndpointUri("direct:marshal");
    final CountDownLatch latch = new CountDownLatch(warmupCount + testCycleCount);

    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:marshal")
                    .marshal(new JaxbDataFormat("org.apache.camel.example"))
                    .process(new Processor() {
                        @Override
                        public void process(Exchange exchange) throws Exception {
                            latch.countDown();
                        }
                    });
        }
    });

    marshal(latch);
}
项目:Camel    文件:RouteWithErrorHandlerTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0));

            onException(InvalidOrderException.class).maximumRedeliveries(0).handled(true)
                .to("mock:invalid");

            DataFormat jaxb = new JaxbDataFormat("org.apache.camel.example");

            from("direct:start")
                .unmarshal(jaxb)
                .choice()
                    .when().method(RouteWithErrorHandlerTest.class, "isWine").to("mock:wine")
                    .otherwise().throwException(new InvalidOrderException("We only like wine"))
                .end();
        }
    };
}
项目:Camel    文件:JaxbDataFormatMustBeJAXBElementTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            JaxbDataFormat jaxb = new JaxbDataFormat(JAXBContext.newInstance(Foo.class));
            jaxb.setPrettyPrint(false);
            jaxb.setMustBeJAXBElement(false);

            from("direct:start").marshal(jaxb).to("log:xml", "mock:result");

            JaxbDataFormat jaxb2 = new JaxbDataFormat(JAXBContext.newInstance(Foo.class));
            jaxb2.setPrettyPrint(false);
            jaxb2.setMustBeJAXBElement(true);

            from("direct:start2").marshal(jaxb2).to("log:xml", "mock:result2");
        }
    };
}
项目:Camel    文件:CamelJaxbNoNamespaceSchemaTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() throws Exception {
            JaxbDataFormat dataFormat = new JaxbDataFormat("org.apache.camel.foo.bar");
            dataFormat.setNoNamespaceSchemaLocation("person-no-namespace.xsd");
            dataFormat.setIgnoreJAXBElement(false);


            from("direct:marshal")
                .marshal(dataFormat)
                .to("mock:result");

        }
    };
}
项目:camelinaction2    文件:InventoryRoute.java   
@Override
public void configure() throws Exception {
    JaxbDataFormat jaxb = new JaxbDataFormat();
    jaxb.setContextPath("camelinaction");

    // TODO: due activemq bug we need to configure it here also
    ActiveMQComponent jms = new ActiveMQComponent(getContext());
    jms.setBrokerURL("tcp://localhost:61616");
    getContext().addComponent("jms", jms);

    from("direct:inventory")
        .log("Calling inventory service using JMS")
        .hystrix()
            // call the legacy system using JMS
            .to("jms:queue:inventory")
            // the returned data is in XML format so convert that to POJO using JAXB
            .unmarshal(jaxb)
        .onFallback()
            .log("Circuit breaker failed so using fallback response")
            // fallback and read inventory from classpath which is in XML format
            .transform().constant("resource:classpath:fallback-inventory.xml");
}
项目:camelinaction2    文件:InventoryRoute.java   
@Override
public void configure() throws Exception {
    JaxbDataFormat jaxb = new JaxbDataFormat();
    jaxb.setContextPath("camelinaction");

    // TODO: due activemq bug we need to configure it here also
    ActiveMQComponent jms = new ActiveMQComponent(getContext());
    jms.setBrokerURL("tcp://localhost:61616");
    getContext().addComponent("jms", jms);

    from("direct:inventory")
        .log("Calling inventory service using JMS")
        .hystrix()
            // call the legacy system using JMS
            .to("jms:queue:inventory")
            // the returned data is in XML format so convert that to POJO using JAXB
            .unmarshal(jaxb)
        .onFallback()
            .log("Circuit breaker failed so using fallback response")
            // fallback and read inventory from classpath which is in XML format
            .transform().constant("resource:classpath:fallback-inventory.xml");
}
项目:camelinaction2    文件:InventoryRoute.java   
@Override
public void configure() throws Exception {
    JaxbDataFormat jaxb = new JaxbDataFormat();
    jaxb.setContextPath("camelinaction");

    from("direct:inventory")
        .log("Calling inventory service using JMS")
        .hystrix()
            // call the legacy system using JMS
            .to("jms:queue:inventory")
            // the returned data is in XML format so convert that to POJO using JAXB
            .unmarshal(jaxb)
        .onFallback()
            // fallback and read inventory from classpath which is in XML format
            .transform().constant("resource:classpath:fallback-inventory.xml");
}
项目:metasfresh    文件:PRTPrinterPackageResponseRoute.java   
@Override
public void configure()
{
    final DataFormat jaxb = new JaxbDataFormat(JAXBConstants.JAXB_ContextPath);

    onException(Exception.class)
            .handled(true)
            .transform(exceptionMessage())
            .to(PRTRestServiceRoute.EP_CXF_RS_ERROR);

    errorHandler(deadLetterChannel(PRTRestServiceRoute.EP_CXF_RS_ERROR));

    from(PRTRestServiceRoute.EP_PrintPackageResponse)
            .routeId("send-print-job-response")
            // unmarshalling was already done by cxf
            // unmarshal().json(JsonLibrary.Jackson, PrintJobInstructionsConfirm.class)
            // POST POJO to ADempiere POJO conversion
            .split().method(PRTCPrintJobInstructionsConfirmTypeBean.class, PRTCPrintJobInstructionsConfirmTypeBean.METHOD_mkPRTADPrintPackageResponseRequest)
            // marshal to ADempiere request format
            .marshal(jaxb)
            // finally, send the data to the ADempiere Request Handler and listen to the response
            .to(Constants.EP_JMS_TO_AD);
}
项目:metasfresh    文件:PRTPrinterHWRoute.java   
@Override
public void configure()
{
    final DataFormat jaxb = new JaxbDataFormat(JAXBConstants.JAXB_ContextPath);

    onException(Exception.class)
            .handled(true)
            .transform(exceptionMessage())
            .to(PRTRestServiceRoute.EP_CXF_RS_ERROR);

    errorHandler(deadLetterChannel(PRTRestServiceRoute.EP_CXF_RS_ERROR));

    from(PRTRestServiceRoute.EP_PrinterHW)
            .routeId("add-printer-hw")

            // note: unmarshaling the POSTed arguments is already done by the cxf component

            // POST POJO to ADempiere POJO conversion
            .split().method(PRTADPrinterHWTypeBean.class, PRTADPrinterHWTypeBean.METHOD_mkPRTADPrinterHWRequest)
            // marshal to ADempiere request format
            .marshal(jaxb)
            // finally, send the data to the ADempiere Request Handler and listen to the response
            .to(Constants.EP_JMS_TO_AD);
}
项目:metasfresh    文件:AbstractEDIRoute.java   
/**
 * <a href="http://www.smooks.org/mediawiki/index.php?title=V1.5:Smooks_v1.5_User_Guide#Apache_Camel_Integration"> Read more about Smooks Integration</a>
 */
@Override
public final void configure()
{
    // Generic Exception and DeadLetterChannel handlers
    onException(Exception.class)
            .handled(true)
            .to(AbstractEDIRoute.EP_EDI_ERROR);

    errorHandler(deadLetterChannel(AbstractEDIRoute.EP_EDI_DEADLETTER)
            .useOriginalMessage()
            .disableRedelivery());

    final JaxbDataFormat jaxbDataFormat = new JaxbDataFormat(Constants.JAXB_ContextPath);
    final DecimalFormat decimalFormat = getDecimalFormatForConfiguration();
    configureEDIRoute(jaxbDataFormat, decimalFormat);
}
项目:switchyard    文件:GreetingServiceRoute.java   
@Override
public void configure() throws Exception {
    JaxbDataFormat jxb = new JaxbDataFormat(JAXBContext.newInstance("org.switchyard.quickstarts.camel.jaxb"));
    from("switchyard://GreetingService")
        .convertBodyTo(String.class)
        .unmarshal(jxb)
        .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                GreetingRequest rq = exchange.getIn().getBody(GreetingRequest.class);
                GreetingResponse rp = new GreetingResponse("Ola " + rq.getName() + "!");

                SwitchYardMessage out = new SwitchYardMessage();
                out.setBody(rp);
                exchange.setOut(out);
            }
        })
        .marshal(jxb)
        .convertBodyTo(String.class);
}
项目:wildfly-camel    文件:RestSwaggerIntegrationTest.java   
@Test
public void testRestSwaggerXML() throws Exception {
    JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);
    JaxbDataFormat jaxb = new JaxbDataFormat(jaxbContext);

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:getCustomerById")
            .to("customer:getCustomerById")
            .unmarshal(jaxb);
        }
    });

    RestSwaggerComponent restSwaggerComponent = new RestSwaggerComponent();
    restSwaggerComponent.setSpecificationUri(new URI("http://localhost:8080/api/swagger"));
    restSwaggerComponent.setComponentName("undertow");
    restSwaggerComponent.setConsumes(MediaType.APPLICATION_XML);
    restSwaggerComponent.setProduces(MediaType.APPLICATION_XML);

    camelctx.addComponent("customer", restSwaggerComponent);

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        Customer customer = template.requestBodyAndHeader("direct:getCustomerById", null, "id", 1, Customer.class);
        Assert.assertNotNull(customer);
        Assert.assertEquals(1, customer.getId());
    } finally {
        camelctx.stop();
    }
}
项目:Camel    文件:IncrementRoute.java   
@Override
public void configure() throws Exception {
    JaxbDataFormat jaxb = new JaxbDataFormat(IncrementRequest.class.getPackage().getName());

    from("spring-ws:rootqname:{http://camel.apache.org/example/increment}incrementRequest?endpointMapping=#endpointMapping")
        .unmarshal(jaxb)
        .process(new IncrementProcessor())
        .marshal(jaxb);
}
项目:Camel    文件:DataFormatDataSetTest.java   
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            DataFormat jaxb = new JaxbDataFormat("org.apache.camel.example");

            // use 5 concurrent threads to do marshalling
            from("dataset:beer").marshal(jaxb).to("dataset:beer");
        }
    };
}
项目:Camel    文件:DataFormatConcurrentTest.java   
@Override
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            DataFormat jaxb = new JaxbDataFormat("org.apache.camel.example");

            // use seda that supports concurrent consumers for concurrency
            from("seda:start?size=" + size + "&concurrentConsumers=5")
                    .marshal(jaxb)
                    .convertBodyTo(String.class)
                    .to("mock:result");
        }
    };
}
项目:Camel    文件:JaxbConcurrentDataFormatTest.java   
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            DataFormat jaxb = new JaxbDataFormat("org.apache.camel.example");

            from("direct:start").
                    marshal(jaxb).
                    to("direct:marshalled");

            from("direct:marshalled").
                    unmarshal(jaxb).
                    to("mock:result");
        }
    };
}
项目:Camel    文件:UnmarshalTest.java   
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            DataFormat jaxb = new JaxbDataFormat("org.apache.camel.example");

            from("direct:start").
                    unmarshal(jaxb).
                    to("mock:result");
        }
    };
}
项目:Camel    文件:JaxbDataFormatIssueTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            JaxbDataFormat jaxb = new JaxbDataFormat(JAXBContext.newInstance(Foo.class));
            jaxb.setPrettyPrint(false);

            from("direct:start").marshal(jaxb).to("log:xml", "mock:result");
        }
    };
}
项目:metasfresh    文件:PRTPrintPackageDataRoute.java   
@Override
public void configure()
{
    final DataFormat jaxb = new JaxbDataFormat(JAXBConstants.JAXB_ContextPath);

    onException(Exception.class)
            .handled(true)
            .transform(exceptionMessage())
            .to(PRTRestServiceRoute.EP_CXF_RS_ERROR);

    errorHandler(deadLetterChannel(PRTRestServiceRoute.EP_CXF_RS_ERROR));

    from(PRTRestServiceRoute.EP_PrintPackageData)
            //
            // Make an xml print package object which adempiere will fill with the required data
            .process(new GetPrintPackageDataADRequestProcessor())
            //
            // Send the object to adempiere and wait for a response
            .marshal(jaxb)
            .inOut(Constants.EP_JMS_TO_AD)
            //
            // Once we have the response, we convert the object to the printing client-specific POJO
            .unmarshal(jaxb)
            //
            // Now convert the exchange to a Base64-encoded byte array (the document itself) as the response to the http request
            .process(new GetPrintPackageDataADResponseProcessor())
            //
            // Send it to archive
            .to(Constants.EP_PRINT_PACKAGE_DATA_ARCHIVE);
}
项目:cxf_over_jms_kata    文件:JaxbTest.java   
@Override
public void configure() {
    DataFormat myJaxb = new JaxbDataFormat("pl.java.scalatech.spring_camel.beans");
    //TODO : direct problem !
    from("seda:xml").marshal().jaxb().to("stream:out");
    Customer cust = new Customer("slawek", "borowiec", "przodownik", new BigDecimal(20000));
    getContext().createProducerTemplate().sendBody("seda:xml", cust);

}
项目:camel-cookbook-examples    文件:NormalizerRoute.java   
@Override
public void configure() throws Exception {
    final DataFormat bindy = new BindyCsvDataFormat(org.camelcookbook.transformation.csv.model.BookModel.class);
    final DataFormat jaxb = new JaxbDataFormat("org.camelcookbook.transformation.myschema");

    final XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
    xmlJsonFormat.setRootName("bookstore");
    xmlJsonFormat.setElementName("book");
    xmlJsonFormat.setExpandableProperties(Arrays.asList("author", "author"));

    from("direct:start")
        .choice()
        .when(header(Exchange.FILE_NAME).endsWith(".csv"))
            .unmarshal(bindy)
            .bean(MyNormalizer.class, "bookModelToJaxb")
            .to("mock:csv")
        .when(header(Exchange.FILE_NAME).endsWith(".json"))
            .unmarshal(xmlJsonFormat)
            .to("mock:json")
        .when(header(Exchange.FILE_NAME).endsWith(".xml"))
            .unmarshal(jaxb)
            .to("mock:xml")
        .otherwise()
            .to("mock:unknown")
            .stop()
        .end()
        .to("mock:normalized");
}
项目:camel-cookbook-examples    文件:JaxbRoute.java   
@Override
public void configure() throws Exception {
    DataFormat myJaxb = new JaxbDataFormat("org.camelcookbook.transformation.myschema");

    from("direct:marshal")
        .marshal(myJaxb)
        .to("mock:marshalResult");

    from("direct:unmarshal")
        .unmarshal(myJaxb)
        .to("mock:unmarshalResult");
}
项目:Camel    文件:CamelJaxbTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() throws Exception {
            JaxbDataFormat dataFormat = new JaxbDataFormat("org.apache.camel.foo.bar");
            dataFormat.setSchemaLocation("person.xsd");
            dataFormat.setIgnoreJAXBElement(false);

            JaxbDataFormat filterEnabledFormat = new JaxbDataFormat("org.apache.camel.foo.bar");
            filterEnabledFormat.setFilterNonXmlChars(true);

            JaxbDataFormat customWriterFormat = new JaxbDataFormat("org.apache.camel.foo.bar");
            customWriterFormat.setXmlStreamWriterWrapper(new TestXmlStreamWriter());

            JaxbDataFormat customWriterAndFilterFormat = new JaxbDataFormat("org.apache.camel.foo.bar");
            customWriterAndFilterFormat.setFilterNonXmlChars(true);
            customWriterAndFilterFormat.setXmlStreamWriterWrapper(new TestXmlStreamWriter());

            from("direct:getJAXBElementValue")
                .unmarshal(new JaxbDataFormat("org.apache.camel.foo.bar"))                        
                    .to("mock:result");

            from("direct:getJAXBElement")
                .unmarshal(dataFormat)
                .to("mock:result");

            from("direct:unmarshalFilteringEnabled")
                .unmarshal(filterEnabledFormat)
                .to("mock:result");

            from("direct:marshal")
                .marshal(dataFormat)
                .to("mock:result");

            from("direct:marshalFilteringEnabled")
                .marshal(filterEnabledFormat)
                .to("mock:result");

            from("direct:marshalCustomWriter")
                    .marshal(customWriterFormat)
                    .to("mock:result");
            from("direct:marshalCustomWriterAndFiltering")
                    .marshal(customWriterAndFilterFormat)
                    .to("mock:result");

            from("direct:unmarshall")
                .unmarshal()
                .jaxb(PersonType.class.getPackage().getName())
                .to("mock:result");

        }
    };
}
项目:metasfresh    文件:PRTNextPrintPackageRoute.java   
@Override
public void configure()
{
    final DataFormat jaxb = new JaxbDataFormat(JAXBConstants.JAXB_ContextPath);

    onException(Exception.class)
            .handled(true)
            .transform(exceptionMessage())
            .to(PRTRestServiceRoute.EP_CXF_RS_ERROR);

    errorHandler(deadLetterChannel(PRTRestServiceRoute.EP_CXF_RS_ERROR));

    // @formatter:off
    from(PRTRestServiceRoute.EP_NextPrintPackage)

            // Use the input's sessionId and transactionId to construct a xml print package object which metasfresh will fill with the required data
            .process(new GetNextPrintPackageADRequestProcessor())

            .marshal(jaxb)
            // Set the body as a property for backup in case the response is null
            .setProperty(PROPERTY_ORIGINAL_BODY, bodyAs(String.class))

            .doTry()
                // Send the object to metasfresh and wait for a response
                .inOut(Constants.EP_JMS_TO_AD)

            .doCatch(Exception.class)
                // in case of an exception, return the original (empty) print package
                .transform(exchangeProperty(PROPERTY_ORIGINAL_BODY))
                .log(LoggingLevel.WARN, "Caught Exception: " + exceptionMessage())
            .end()

            // If the received body is null, set it with the previously set property
            .choice()
                .when(body().isNull())
                    .transform(exchangeProperty(PROPERTY_ORIGINAL_BODY))
            .end()

            .unmarshal(jaxb)

            // Once we have the response, we convert the object to the printing client-specific POJO
            .process(new GetNextPrintPackageADResponseProcessor());
            // marshaling is already done by cxf
    // @formatter:on
}
项目:metasfresh    文件:EDIFeedbackRoute.java   
@Override
public void configure()
{
    // Catch any exception in feedback, log it, and stop the route from continuing execution.
    onException(Exception.class)
            .handled(true)
            .log(LoggingLevel.ERROR, property(Exchange.EXCEPTION_CAUGHT).toString())
            .to(AbstractEDIRoute.EP_EDI_LOG_ExceptionHandler)
            .stop();

    // At the moment, there's no need to differentiate between the DeadLetterChannel and Exception,
    // so send them both to the same queue to avoid duplicate code
    from(AbstractEDIRoute.EP_EDI_ERROR)
            .to(EDIFeedbackRoute.EP_EDI_ERROR_COMMON);

    from(AbstractEDIRoute.EP_EDI_DEADLETTER)
            .to(EDIFeedbackRoute.EP_EDI_ERROR_COMMON);

    final Processor errorInvoiceProcessor = new EDIXmlErrorFeedbackProcessor<EDIInvoiceFeedbackType>(EDIInvoiceFeedbackType.class,
            EDIInvoiceRoute.EDIInvoiceFeedback_QNAME, EDIInvoiceRoute.METHOD_setCInvoiceID); // FIXME ugly
    final Processor errorInOutProcessor = new EDIXmlErrorFeedbackProcessor<EDIInOutFeedbackType>(EDIInOutFeedbackType.class,
            EDIDesadvRoute.EDIInOutFeedback_QNAME, EDIDesadvRoute.METHOD_setMInOutID); // FIXME ugly
    final Processor errorDesadvProcessor = new EDIXmlErrorFeedbackProcessor<EDIDesadvFeedbackType>(EDIDesadvFeedbackType.class,
            EDIDesadvRoute.EDIDesadvFeedback_QNAME, EDIDesadvRoute.METHOD_setEDIDesadvID); // FIXME ugly

    // @formatter:off
    from(EDIFeedbackRoute.EP_EDI_ERROR_COMMON)
            .to(AbstractEDIRoute.EP_EDI_LOG_ExceptionHandler)
            .choice()
                .when(property(AbstractEDIRoute.IS_CREATE_XML_FEEDBACK).isEqualTo(true))
                    .log(LoggingLevel.INFO, "EDI: Creating error feedback XML Java Object...")
                    .choice()
                        //.when(body().isInstanceOf(EDICctopInvoicVType.class))
                        .when(header(EDIXmlFeedbackHelper.HEADER_ROUTE_ID).isEqualTo(EDIInvoiceRoute.ROUTE_ID))
                            .process(errorInvoiceProcessor)
                        .when(header(EDIXmlFeedbackHelper.HEADER_ROUTE_ID).isEqualTo(EDIDesadvRoute.ROUTE_ID_SINGLE))
                            .process(errorInOutProcessor)
                        .when(header(EDIXmlFeedbackHelper.HEADER_ROUTE_ID).isEqualTo(EDIDesadvRoute.ROUTE_ID_AGGREGATE))
                            .process(errorDesadvProcessor)
                        .otherwise()
                            .log(LoggingLevel.ERROR, "EDI: No available feedback processor found for header[HEADER_ROUTE_ID]=" + header(EDIXmlFeedbackHelper.HEADER_ROUTE_ID))
                            .stop() // if there's no error handler, just forget about it...
                    .end()
                    .log(LoggingLevel.INFO,"EDI: Marshalling error feedback XML Java Object -> XML document...")
                    .marshal(new JaxbDataFormat(Constants.JAXB_ContextPath))
                    // Add the extension for the Feedback object so that it opens nicely :)
                    // (the extension is hard-coded, as i didn't see a real reason to keep it in properties --
                    // this can be removed at any time)
                    .setHeader(Exchange.FILE_NAME, property(Exchange.FILE_NAME).append(".error.xml"))
                    // If errors occurred, put the feedback in the error directory
                    .to(EDIFeedbackRoute.EP_EDI_LOCAL_ERROR)
                    // Send the feedback to ADempiere
                    .log(LoggingLevel.INFO, "EDI: Sending error response to ADempiere...")
                    .to(Constants.EP_JMS_TO_AD)
            .end();
    // @formatter:on
}
项目:camel_cxfrs_spring_boot_java_dsl    文件:MySpringBootRouter.java   
@Override
public void configure() throws JAXBException {

    //Camel rest server configuration
    restConfiguration()
        .component("restlet")
        .port(routerConfig.getPort())
        .host(routerConfig.getHost());

    //rest endpoint configuration
    rest("/monnitmysqltsdb")
        .post()
        .to("direct:monnitmysqltsdb");

    //unmarshal configuration
    JaxbDataFormat jaxb = new JaxbDataFormat(JAXBContext.newInstance(MonnitData.class));        
    jaxb.setContextPath(CustomConverter.class.getPackage().getName());      

    //multicast parallel processing thread pool size configuration
    ExecutorService executor = Executors.newFixedThreadPool(10);

    from("direct:monnitmysqltsdb")
        .multicast()
        .parallelProcessing()
        .executorService(executor)
        .to("direct:monnittsdb", "direct:monnitmysql" );

    from("direct:monnitmysql")
        .split()
        .tokenizeXML("APIDataMessage").streaming()
        .unmarshal(jaxb)
        .convertBodyTo(com.samples.apache.camel.springboot.helpers.MeasurementEventDTO.class)
        .setHeader("Content-Type", constant("application/json"))
        .to("cxfrs://bean://monnitClient");

    from("direct:monnittsdb")
    .split()
    .tokenizeXML("APIDataMessage").streaming()
    .unmarshal(jaxb)
    .convertBodyTo(com.samples.apache.camel.springboot.helpers.MeasurementEventDTO.class)
    .setHeader("Content-Type", constant("application/json"))
    .to("cxfrs://bean://tsdbData");
}