简体   繁体   中英

Apache camel as a reverse proxy

Can Apache Camel be used as a reverse proxy? I'm aware that camel is a routing engine and can be used to consume messages from different kinds of endpoints/ components. However i'm not sure whether camel can be used for the following requirement?

  • when requests coming to /context-root , consume from this REST endpoint
  • and invoke another rest service /new-context-root with same request params
  • then send response of /new-context-root as the response to /context-root

Is this possible with camel?

Yes this is perfectly possible. Although let me first say that acting as an API proxy is not Camel's main contextual use, but it can be used in the case you are describing.

A simple example (though you need to "clean the code").

from("restlet:http://localhost:80" + "/context-root?restletMethods=get")
to("restlet:http://localhost:81"+"/context-root1?restletMethod=get);

You can create processors to change the body in between the calls or change the headers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM