Add route to apache camel CamelContext - Java Message

Java examples for Message:apache camel

Description

Add route to apache camel CamelContext

Demo Code


import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class Send {

    public static void main(String args[]) throws Exception {

        CamelContext context = new DefaultCamelContext();

        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("timer://simple?period=1")
                        .setBody()//from w w w . j a v a 2s . co  m
                        .simple("Test message: ${in.headers.CamelTimerCounter}")
                        .to("rabbitmq://localhost?queue=task_queue&durable=true&messageProperties=PERSISTENT_TEXT_PLAIN");
            }
        });
        context.start();
    }

}

Related Tutorials