"Java.Apache.Camel"

Source: Internet
Author: User

Apache camel--A Enterprise integration patterns, reference to Enterprise Integration mode: Designing, building, and deploying messaging solutions.

Provides message routing route: The basic function is to accept messages, process messages, and assign messages.

Configure Routing and processing rules through the Java domain-specific language DSL (based on the Java API provided by Camel, or the spring configuration file, etc.). Its core idea is to get data from a source, through processor processing, and then sending it to another to destination.


Camel uses URIs to represent different message transfer models.


Currently supported types of URIs:

disruptor://

file://

ftp://

hbase://

hdfs://

http://

ibatis://

jdbc://

jms://

jmx://

jpa://

ldap://

quartz://

rmi://

quickfix://

smtp://

Sql:

Zookeeper:

spring-redis://

, ... etc .....


Third-party extensions:

activemq://

hibernate://

zeromq://

, ... etc .....



e.g.

E1:FTP-File System routing


Camelcontext context = new Defaultcamelcontext ();  
Context.addroutes (New Routebuilder () {public  
    void Configure () {                            
        "ftp://localhost/inbox?username= yorker&password=123456 "). to (  
        " File:d:/temp/outbox ");  
    }  
);  
Context.start ();  
Boolean loop = true;  
while (loop) {  
    thread.sleep (25000);  
}  
  

E2:JMS Routing


private static String user = Activemqconnection.default_user;  
private static String password = Activemqconnection.default_password;  
  
private static String URL = activemqconnection.default_broker_url;          
    public static void Main (String args[]) throws the Exception {camelcontext context = new Defaultcamelcontext ();  
    ConnectionFactory connectionfactory = new activemqconnectionfactory (user, password, URL);  
    Context.addcomponent ("JMS", Jmscomponent.jmscomponentautoacknowledge (ConnectionFactory));          
    System.out.println (URL + "" + user + password); Context.addroutes (New Routebuilder () {public void Configure () {"File:d:/tem P/inbox "). to (" Jms:queue:TOOL.  
        DEFAULT ");  
    }  
    });  
    Context.start ();  
    Boolean loop = true;  
    while (loop) {thread.sleep (25000);  
} context.stop (); }  


E3:http Routing



public class Httppollwithquartzcamel {public  
    static void Main (String args[]) throws Exception {  
        Camelcontext con Text = new Defaultcamelcontext ();  
        Context.addroutes (New Routebuilder () {public  
            void Configure () {from                  
                ("quartz://report?cron=10 * * * * *?& Stateful=true ")  
                . to (" Http://localhost:8080/prjWeb/test.camelreq ")  
                . to (" File:d:/temp/outbox?filename= Http.csv ");  
                );  
        Context.start ();  
        Boolean loop = true;  
        while (loop) {  
            thread.sleep (25000);  
        }  
        Context.stop ();  
    }  
  



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.