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 ();
}