camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Camel > How to use Camel as a HTTP proxy between a client and server
Date Wed, 23 Nov 2011 10:16:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="">How
to use Camel as a HTTP proxy between a client and server</a></h2>
    <h4>Page  <b>added</b> by             <a href="">Claus
    <div class="notificationGreySide">
         <h2><a name="HowtouseCamelasaHTTPproxybetweenaclientandserver-HowtouseCamelasaHTTPproxybetweenaclientandserver"></a>How
to use Camel as a HTTP proxy between a client and server</h2>

<p>You may have an existing HTTP service, which you want to use Camel in between as
a proxy, between the client and the server.</p>

<p>This can be done using the <a href="/confluence/display/CAMEL/Jetty" title="Jetty">Jetty</a>
component as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
  <span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag">&lt;from uri=<span class="code-quote">"jetty:"</span>/&gt;</span>
    <span class="code-tag">&lt;to uri=<span class="code-quote">"jetty:http://realserverhostname:8090/myapp?bridgeEndpoint=true&amp;amp;throwExceptionOnFailure=false"</span>/&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>

<p>In the example above, we expose a HTTP service on localhost ( means to expose
on all network interfaces) port 8080, and using context path "myapp".<br/>
The option <tt>matchOnUriPrefix</tt> is set to <tt>true</tt>, to match
any wildcards in the "myapp" context path. See more details here <a href="/confluence/display/CAMEL/How+do+I+let+Jetty+match+wildcards"
title="How do I let Jetty match wildcards">How do I let Jetty match wildcards</a>.</p>

<p>Then we route to the <tt>&lt;to&gt;</tt> which is also a jetty
endpoint, which sends the requests to the real HTTP server. The bridgeEndpoint is set to true,
to tell Camel that its a bridging from an incoming <a href="/confluence/display/CAMEL/Jetty"
title="Jetty">Jetty</a> service (ie. to act as a HTTP adapter/proxy). The option
<tt>throwExceptionOnFailure</tt> is set to <tt>true</tt>, to rely
back any errors communicating wit the real HTTP server directly to the client, without using
any Camel <a href="/confluence/display/CAMEL/Error+handling+in+Camel" title="Error handling
in Camel">Error Handling</a>.</p>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message