Search in sources :

Example 1 with JaxbDataFormat

use of org.apache.camel.converter.jaxb.JaxbDataFormat in project camel by apache.

the class DataFormatConcurrentTest method testMarshallConcurrent.

@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);
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat) Test(org.junit.Test)

Example 2 with JaxbDataFormat

use of org.apache.camel.converter.jaxb.JaxbDataFormat in project camel by apache.

the class DataFormatConcurrentTest method createRouteBuilder.

@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");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DataFormat(org.apache.camel.spi.DataFormat) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat)

Example 3 with JaxbDataFormat

use of org.apache.camel.converter.jaxb.JaxbDataFormat in project camel by apache.

the class DataFormatTest method createRouteBuilder.

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");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat)

Example 4 with JaxbDataFormat

use of org.apache.camel.converter.jaxb.JaxbDataFormat in project camel by apache.

the class JaxbConcurrentDataFormatTest method createRouteBuilder.

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");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DataFormat(org.apache.camel.spi.DataFormat) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat)

Example 5 with JaxbDataFormat

use of org.apache.camel.converter.jaxb.JaxbDataFormat in project camel by apache.

the class RouteWithErrorHandlerTest method createRouteBuilder.

@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();
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DataFormat(org.apache.camel.spi.DataFormat) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat) JaxbDataFormat(org.apache.camel.converter.jaxb.JaxbDataFormat)

Aggregations

JaxbDataFormat (org.apache.camel.converter.jaxb.JaxbDataFormat)17 RouteBuilder (org.apache.camel.builder.RouteBuilder)14 DataFormat (org.apache.camel.spi.DataFormat)6 Exchange (org.apache.camel.Exchange)3 Processor (org.apache.camel.Processor)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 JAXBContext (javax.xml.bind.JAXBContext)1 CamelContextAware (org.apache.camel.CamelContextAware)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 PersonType (org.apache.camel.foo.bar.PersonType)1 DataFormatFactory (org.apache.camel.spi.DataFormatFactory)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 SwitchYardMessage (org.switchyard.common.camel.SwitchYardMessage)1