Camel Study Notes (1)

Source: Internet
Author: User
Tags enterprise integration patterns apache camel

 

I have just arrived at a new organization and have no specific tasks. I look at high-performance computing and cloud computing every day. In addition, I am engaged in some research to make some technical reserves for future project implementation. Camel is the first open-source project.

 

Apache camel is an excellent open-source project. It is a very powerful rule-based routing and media engine that provides a pojo-based enterprise integration patterns) you can use an extremely powerful and easy-to-use API to configure routing or mediation rules.

Apache camel uses URI to describe various components, so that you can easily interact with a variety of transmission or message modules, including HTTP, activemq, JMS, jbi, SCA, mina or cxf bus API. These modules work in a pluggable manner. The core of Apache camel is very small and you can easily integrate it into various Java applications.

 

For more information, see.

 

In addition, a Chinese cool is one of the maintainers of this project. I have discussed something with him in the Forum. He is Willem Jiang and Jiangning. He also gave a very detailed answer to my very simple question. I would like to thank him first.

 

Let's talk about my research goals first. The first step is very simple. I want to use camel to receive HTTP requests and print them out. The HTTP server uses jetty.

 

Import Org. apache. camel. camelcontext; <br/> Import Org. apache. camel. exchange; <br/> Import Org. apache. camel. processor; <br/> Import Org. apache. camel. builder. routebuilder; <br/> Import Org. apache. camel. impl. defaultcamelcontext; </P> <p>/** <br/> * @ author Chen Yi <njchenyi@gmail.com> <br/> */<br/> public class httptofileroute {</P> <p> Public static void main (string ARGs []) throws exception {<br/> camelcontext context = new defaultcamelcontext (); <br/> context. addroutes (New routebuilder () {</P> <p> Public void configure () {<br/> from ("jetty: http: // 0.0.0.0: 8080 /"). process (new processor () {<br/> Public void process (exchange e) throws ioexception {<br/> system. out. println ("stored ed exchange:" + E. getin (); <br/> system. out. println (E. getin (). getbody (string. class); <br/>}< br/>}); <br/> context. start (); </P> <p> thread. sleep (30000); // Let HTTP server works 30 seconds <br/> context. stop (); <br/>}< br/>

 

A simple program, and then use soapui to simulate an HTTP client to send a request to port 127.0.0.1: 8080, you can see that the console has text output.

The first part is:

Received exchange: Message: [body is instance of Java. Io. inputstream]

The second part is the HTTP Request body, which is displayed in text format.

The statements here are very simple. If you do not quite understand it, you are advised to go to the official website to take a look at the most basic introduction.

In addition, the jar package to be prepared is as follows:

Activation-1.1.jar

Aopalliance-1.0.jar

Camel-core-2.1.0.jar

Camel-http-2.1.0.jar

Camel-jetty-2.1.0.jar

Camel-spring-2.1.0.jar

Camel-test-2.1.0.jar

Commons-codec-1.3.jar

Commons-httpclient-3.1.jar

Commons-logging-1.1.1.jar

Commons-management-1.0.jar

Geronimo-servlet_2.4_spec-1.1.1.jar

Jaxb-api-2.1.jar

Jaxb-impl-2.1.12.jar

Jetty-6.1.16.jar

Jetty-client-6.1.16.jar

Jetty-sslengine-6.1.16.jar

Jetty-util5-6.1.16.jar

Jetty-util-6.1.16.jar

Junit-4.4.jar

Log4j-1.2.14.jar

Servlet-api-2.5-20081211.jar

Spring-aop-2.5.6.jar

Spring-beans-2.5.6.jar

Spring-context-2.5.6.jar

Spring-core-2.5.6.jar

Spring-tx-2.5.6.jar

Stax-api-1.0-2.jar

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.