Camel running example, camel example

Source: Internet
Author: User

Camel running example, camel example

This is a simple Camel example. The Code is as follows:

Public static void main (String [] args) throws Exception {// create the Camel context DefaultCamelContext camelContext = new DefaultCamelContext (); // Add a route with the parameter "camelContext" as the route builder. addRoutes (new RouteBuilder () {@ Overridepublic void configure () throws Exception {this. from ("file: H:/temp/in "). process (new Processor () {@ Overridepublic void process (Exchange exchange) throws Exception {GenericFile <File> gf = exchange. getIn (). GetBody (GenericFile. class); File file = gf. getFile (); PrintStream ps = new PrintStream (System. out); BufferedReader br = new BufferedReader (new InputStreamReader (new FileInputStream (file); String line = null; while (line = br. readLine ())! = Null) {ps. println (line);} ps. close (); br. close ();}}). to ("file: H:/temp/out") ;}}); // start the context camelContext. start (); // prevent the main thread from exiting the Object object = new Object (); synchronized (object) {object. wait ();}}

The reason for writing this example is not to mention how much things can be learned through the surface energy of this example, but to find out the operating mechanism and principle behind it through this example. The route configuration here is very simple. A starting node, a processor, and a target node are designed to move files in one directory to another folder. The processor only transfers files (limited to text files) to the console.

This example is simple, but it is enough to understand the core operating mechanism of Camel and it will be broken down later.


In windows 7, it is best to click where to run a graph example.

Win + R

What is the use of camels?

Camels can endure hunger and thirst. In addition to being used for carrying and riding, camels can also pull cars, which are also known as the "Desert Boat. Mao, skin, meat, milk, dung, and so on can also be used. It is an indispensable means of transportation for people and geological exploration and archaeology in the Gobi Desert. In recent years, it has also been used for farmland, raking grass, and drilling. Camels store fat in their Humr. When camels do not get food, they can be broken down into nutrients needed by their bodies for their survival. Camels can stay away from food for four or five consecutive days, that is, relying on the fat in the hump. In addition, camels have many small bubbles in the shape of bottles in their stomachs, which are the places where camels store water. The water in these "bottles" prevents camels from being in danger even if they do not drink water for a few days.

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.