camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Doepner <>
Subject Full example of configuring endpoints in pure Java (without uri strings)
Date Wed, 02 Aug 2017 16:47:05 GMT

I am trying to use Camel using the pure Java approach (Java DSL, no DI
framework, no URI Strings).

My approach so far is like the simplistic sample below, but I am not sure
if it uses proper practices.

Can you please let me know if/what problems you see with this approach?
Is there maybe documentation somewhere with a full "pure Java" example?

Thank you

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.CxfComponent;
import org.apache.camel.component.cxf.CxfEndpoint;
import org.apache.camel.main.Main;
import org.apache.camel.main.MainListenerSupport;

public class CamelExample {

    public static void main(String... args) throws Exception {

        final Main main = new Main();

        main.addMainListener(new MainListenerSupport() {
            public void configure(CamelContext context) {
                context.addComponent("cxf", new CxfComponent());

                final CxfEndpoint webService = new CxfEndpoint();
                // etc

                Processor requestPreparation = new Processor() {
                    public void process(Exchange exchange) throws Exception
                        exchange.getIn().setBody(new MyServiceRequest());

                        new RouteBuilder() {
                            public void configure() throws Exception {

    /* web service related classes stubbed out to keep example code simple

    private static final class MyService {};
    private static final class MyServiceRequest {};


Oliver Doepner
Software Developer
IMP Solutions, Halifax, NS
Phone 1-902-482-1615

Oliver Doepner
Halifax, Nova Scotia
Buchstabensalat : ßäöüÄÖÜ

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message