You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bhavesh Mistry <mi...@gmail.com> on 2015/06/15 23:56:24 UTC

Apache Camel Routing and Apache CXF Rest with Proxy

Hi All,



I am new to Apache Camel and trying to solve following problem with routing:



I have CXF JAX-RS based REST Service implemented and deployed in same JVM
(end-point).



I have another set of REST Service that is not within same Java Process it
is in (python or any other Process but on same host).





We have unified port to access both services,  for example,



Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
Services)}





     <cxf:rsServer id="javaRestServer" address="
http://localhost:9090/java_api"

         loggingFeatureEnabled="true"

         serviceClass="…." >

         <cxf:providers>

              <ref bean="jaxbProvider" />

              <ref bean="jsonProvider" />

         </cxf:providers>

         <cxf:serviceBeans>

              <ref bean="myService"/>

         </cxf:serviceBeans>

     </cxf:rsServer>





The problem with this approach is there is unnecessary http call for Java
API(java_api) route since it is already locally hosted and we do not want
to incur HTTP call.



This has been done to set-up all the CXF context and be able to server REST
service.



So, my questions are:



1) 1) Is there any way to setup route to call cxf local binding JAX-RS
(direct call) rather then http call for Java API ?

2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g
*X-Forwarded-For
*) gets passed to old Service API ? Since, Java Layer is indeed acting as
proxy server.


Thanks in advance for your help !


Thanks,



Bhavesh

Fwd: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Bhavesh Mistry <mi...@gmail.com>.
Hi All,



I am new to Apache Camel and trying to solve following problem with routing:



I have CXF JAX-RS based REST Service implemented and deployed in same JVM
(end-point).



I have another set of REST Service that is not within same Java Process it
is in (python or any other Process but on same host).





We have unified port to access both services,  for example,



Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
Services)}





     <cxf:rsServer id="javaRestServer" address="
http://localhost:9090/java_api"

         loggingFeatureEnabled="true"

         serviceClass="…." >

         <cxf:providers>

              <ref bean="jaxbProvider" />

              <ref bean="jsonProvider" />

         </cxf:providers>

         <cxf:serviceBeans>

              <ref bean="myService"/>

         </cxf:serviceBeans>

     </cxf:rsServer>





The problem with this approach is there is unnecessary http call for Java
API(java_api) route since it is already locally hosted and we do not want
to incur HTTP call.



This has been done to set-up all the CXF context and be able to server REST
service.



So, my questions are:



1) 1) Is there any way to setup route to call cxf local binding JAX-RS
(direct call) rather then http call for Java API ?

2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g
*X-Forwarded-For
*) gets passed to old Service API ? Since, Java Layer is indeed acting as
proxy server.


Thanks in advance for your help !


Thanks,



Bhavesh

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Aki Yoshida <el...@gmail.com>.
1. If it is a cxf's jaxrs service, you can use the cxf-bean component
to directly call that service.
http://camel.apache.org/cxf-bean-component.html

2. you can just add your headers as Camel headers in the route using setHeader


By the way, you don't need to add dev for usage questions.

2015-06-16 20:55 GMT+02:00 Bhavesh Mistry <mi...@gmail.com>:
> Adding Dev group to see how I can achieve this.
>
> Thanks,
>
> Bhavesh
>
> On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <mi...@gmail.com>
> wrote:
>
>> Hi All,
>>
>>
>>
>> I am new to Apache Camel and trying to solve following problem with
>> routing:
>>
>>
>>
>> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
>> (end-point).
>>
>>
>>
>> I have another set of REST Service that is not within same Java Process it
>> is in (python or any other Process but on same host).
>>
>>
>>
>>
>>
>> We have unified port to access both services,  for example,
>>
>>
>>
>> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
>> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
>> Services)}
>>
>>
>>
>>
>>
>>      <cxf:rsServer id="javaRestServer" address="
>> http://localhost:9090/java_api"
>>
>>          loggingFeatureEnabled="true"
>>
>>          serviceClass="…." >
>>
>>          <cxf:providers>
>>
>>               <ref bean="jaxbProvider" />
>>
>>               <ref bean="jsonProvider" />
>>
>>          </cxf:providers>
>>
>>          <cxf:serviceBeans>
>>
>>               <ref bean="myService"/>
>>
>>          </cxf:serviceBeans>
>>
>>      </cxf:rsServer>
>>
>>
>>
>>
>>
>> The problem with this approach is there is unnecessary http call for Java
>> API(java_api) route since it is already locally hosted and we do not want
>> to incur HTTP call.
>>
>>
>>
>> This has been done to set-up all the CXF context and be able to server
>> REST service.
>>
>>
>>
>> So, my questions are:
>>
>>
>>
>> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
>> (direct call) rather then http call for Java API ?
>>
>> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
>> *) gets passed to old Service API ? Since, Java Layer is indeed acting as
>> proxy server.
>>
>>
>> Thanks in advance for your help !
>>
>>
>> Thanks,
>>
>>
>>
>> Bhavesh
>>
>>
>>

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Bhavesh Mistry <mi...@gmail.com>.
I would appreciate if any one has deal with similar issue as above. I would
appreciate your input.

Thanks,
Bhavesh

On Tue, Jun 16, 2015 at 11:55 AM, Bhavesh Mistry <mistry.p.bhavesh@gmail.com
> wrote:

> Adding Dev group to see how I can achieve this.
>
> Thanks,
>
> Bhavesh
>
> On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <
> mistry.p.bhavesh@gmail.com> wrote:
>
>> Hi All,
>>
>>
>>
>> I am new to Apache Camel and trying to solve following problem with
>> routing:
>>
>>
>>
>> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
>> (end-point).
>>
>>
>>
>> I have another set of REST Service that is not within same Java Process
>> it is in (python or any other Process but on same host).
>>
>>
>>
>>
>>
>> We have unified port to access both services,  for example,
>>
>>
>>
>> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
>> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
>> Services)}
>>
>>
>>
>>
>>
>>      <cxf:rsServer id="javaRestServer" address="
>> http://localhost:9090/java_api"
>>
>>          loggingFeatureEnabled="true"
>>
>>          serviceClass="…." >
>>
>>          <cxf:providers>
>>
>>               <ref bean="jaxbProvider" />
>>
>>               <ref bean="jsonProvider" />
>>
>>          </cxf:providers>
>>
>>          <cxf:serviceBeans>
>>
>>               <ref bean="myService"/>
>>
>>          </cxf:serviceBeans>
>>
>>      </cxf:rsServer>
>>
>>
>>
>>
>>
>> The problem with this approach is there is unnecessary http call for Java
>> API(java_api) route since it is already locally hosted and we do not want
>> to incur HTTP call.
>>
>>
>>
>> This has been done to set-up all the CXF context and be able to server
>> REST service.
>>
>>
>>
>> So, my questions are:
>>
>>
>>
>> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
>> (direct call) rather then http call for Java API ?
>>
>> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
>> *) gets passed to old Service API ? Since, Java Layer is indeed acting
>> as proxy server.
>>
>>
>> Thanks in advance for your help !
>>
>>
>> Thanks,
>>
>>
>>
>> Bhavesh
>>
>>
>>
>
>

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Bhavesh Mistry <mi...@gmail.com>.
I would appreciate if any one has deal with similar issue as above. I would
appreciate your input.

Thanks,
Bhavesh

On Tue, Jun 16, 2015 at 11:55 AM, Bhavesh Mistry <mistry.p.bhavesh@gmail.com
> wrote:

> Adding Dev group to see how I can achieve this.
>
> Thanks,
>
> Bhavesh
>
> On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <
> mistry.p.bhavesh@gmail.com> wrote:
>
>> Hi All,
>>
>>
>>
>> I am new to Apache Camel and trying to solve following problem with
>> routing:
>>
>>
>>
>> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
>> (end-point).
>>
>>
>>
>> I have another set of REST Service that is not within same Java Process
>> it is in (python or any other Process but on same host).
>>
>>
>>
>>
>>
>> We have unified port to access both services,  for example,
>>
>>
>>
>> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
>> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
>> Services)}
>>
>>
>>
>>
>>
>>      <cxf:rsServer id="javaRestServer" address="
>> http://localhost:9090/java_api"
>>
>>          loggingFeatureEnabled="true"
>>
>>          serviceClass="…." >
>>
>>          <cxf:providers>
>>
>>               <ref bean="jaxbProvider" />
>>
>>               <ref bean="jsonProvider" />
>>
>>          </cxf:providers>
>>
>>          <cxf:serviceBeans>
>>
>>               <ref bean="myService"/>
>>
>>          </cxf:serviceBeans>
>>
>>      </cxf:rsServer>
>>
>>
>>
>>
>>
>> The problem with this approach is there is unnecessary http call for Java
>> API(java_api) route since it is already locally hosted and we do not want
>> to incur HTTP call.
>>
>>
>>
>> This has been done to set-up all the CXF context and be able to server
>> REST service.
>>
>>
>>
>> So, my questions are:
>>
>>
>>
>> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
>> (direct call) rather then http call for Java API ?
>>
>> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
>> *) gets passed to old Service API ? Since, Java Layer is indeed acting
>> as proxy server.
>>
>>
>> Thanks in advance for your help !
>>
>>
>> Thanks,
>>
>>
>>
>> Bhavesh
>>
>>
>>
>
>

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Bhavesh Mistry <mi...@gmail.com>.
I would appreciate if any one has deal with similar issue as above. I would
appreciate your input.

Thanks,
Bhavesh

On Tue, Jun 16, 2015 at 11:55 AM, Bhavesh Mistry <mistry.p.bhavesh@gmail.com
> wrote:

> Adding Dev group to see how I can achieve this.
>
> Thanks,
>
> Bhavesh
>
> On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <
> mistry.p.bhavesh@gmail.com> wrote:
>
>> Hi All,
>>
>>
>>
>> I am new to Apache Camel and trying to solve following problem with
>> routing:
>>
>>
>>
>> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
>> (end-point).
>>
>>
>>
>> I have another set of REST Service that is not within same Java Process
>> it is in (python or any other Process but on same host).
>>
>>
>>
>>
>>
>> We have unified port to access both services,  for example,
>>
>>
>>
>> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
>> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
>> Services)}
>>
>>
>>
>>
>>
>>      <cxf:rsServer id="javaRestServer" address="
>> http://localhost:9090/java_api"
>>
>>          loggingFeatureEnabled="true"
>>
>>          serviceClass="…." >
>>
>>          <cxf:providers>
>>
>>               <ref bean="jaxbProvider" />
>>
>>               <ref bean="jsonProvider" />
>>
>>          </cxf:providers>
>>
>>          <cxf:serviceBeans>
>>
>>               <ref bean="myService"/>
>>
>>          </cxf:serviceBeans>
>>
>>      </cxf:rsServer>
>>
>>
>>
>>
>>
>> The problem with this approach is there is unnecessary http call for Java
>> API(java_api) route since it is already locally hosted and we do not want
>> to incur HTTP call.
>>
>>
>>
>> This has been done to set-up all the CXF context and be able to server
>> REST service.
>>
>>
>>
>> So, my questions are:
>>
>>
>>
>> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
>> (direct call) rather then http call for Java API ?
>>
>> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
>> *) gets passed to old Service API ? Since, Java Layer is indeed acting
>> as proxy server.
>>
>>
>> Thanks in advance for your help !
>>
>>
>> Thanks,
>>
>>
>>
>> Bhavesh
>>
>>
>>
>
>

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Bhavesh Mistry <mi...@gmail.com>.
Adding Dev group to see how I can achieve this.

Thanks,

Bhavesh

On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <mi...@gmail.com>
wrote:

> Hi All,
>
>
>
> I am new to Apache Camel and trying to solve following problem with
> routing:
>
>
>
> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
> (end-point).
>
>
>
> I have another set of REST Service that is not within same Java Process it
> is in (python or any other Process but on same host).
>
>
>
>
>
> We have unified port to access both services,  for example,
>
>
>
> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
> Services)}
>
>
>
>
>
>      <cxf:rsServer id="javaRestServer" address="
> http://localhost:9090/java_api"
>
>          loggingFeatureEnabled="true"
>
>          serviceClass="…." >
>
>          <cxf:providers>
>
>               <ref bean="jaxbProvider" />
>
>               <ref bean="jsonProvider" />
>
>          </cxf:providers>
>
>          <cxf:serviceBeans>
>
>               <ref bean="myService"/>
>
>          </cxf:serviceBeans>
>
>      </cxf:rsServer>
>
>
>
>
>
> The problem with this approach is there is unnecessary http call for Java
> API(java_api) route since it is already locally hosted and we do not want
> to incur HTTP call.
>
>
>
> This has been done to set-up all the CXF context and be able to server
> REST service.
>
>
>
> So, my questions are:
>
>
>
> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
> (direct call) rather then http call for Java API ?
>
> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
> *) gets passed to old Service API ? Since, Java Layer is indeed acting as
> proxy server.
>
>
> Thanks in advance for your help !
>
>
> Thanks,
>
>
>
> Bhavesh
>
>
>

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Sergey Beryozkin <sb...@gmail.com>.
Not sure I understand the question. perhaps you'd like to try a cxfrs 
producer/client and cxfrs server/consumer, both set with a local 
transport id ?

Cheers, Sergey
On 24/06/15 19:30, Bhavesh Mistry wrote:
> I just need some help and guidelines with above issue.
>
> Stack-0verflow Question:
> http://stackoverflow.com/questions/30853744/apache-camel-and-cxf-jax-rs-rest-services-end-point-routing-and-proxy-server
>
> Thanks,
> Bhavesh
>
> On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <mi...@gmail.com>
> wrote:
>
>> Hi All,
>>
>>
>>
>> I am new to Apache Camel and trying to solve following problem with
>> routing:
>>
>>
>>
>> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
>> (end-point).
>>
>>
>>
>> I have another set of REST Service that is not within same Java Process it
>> is in (python or any other Process but on same host).
>>
>>
>>
>>
>>
>> We have unified port to access both services,  for example,
>>
>>
>>
>> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
>> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
>> Services)}
>>
>>
>>
>>
>>
>>       <cxf:rsServer id="javaRestServer" address="
>> http://localhost:9090/java_api"
>>
>>           loggingFeatureEnabled="true"
>>
>>           serviceClass="…." >
>>
>>           <cxf:providers>
>>
>>                <ref bean="jaxbProvider" />
>>
>>                <ref bean="jsonProvider" />
>>
>>           </cxf:providers>
>>
>>           <cxf:serviceBeans>
>>
>>                <ref bean="myService"/>
>>
>>           </cxf:serviceBeans>
>>
>>       </cxf:rsServer>
>>
>>
>>
>>
>>
>> The problem with this approach is there is unnecessary http call for Java
>> API(java_api) route since it is already locally hosted and we do not want
>> to incur HTTP call.
>>
>>
>>
>> This has been done to set-up all the CXF context and be able to server
>> REST service.
>>
>>
>>
>> So, my questions are:
>>
>>
>>
>> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
>> (direct call) rather then http call for Java API ?
>>
>> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
>> *) gets passed to old Service API ? Since, Java Layer is indeed acting as
>> proxy server.
>>
>>
>> Thanks in advance for your help !
>>
>>
>> Thanks,
>>
>>
>>
>> Bhavesh
>>
>>
>>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Bhavesh Mistry <mi...@gmail.com>.
I just need some help and guidelines with above issue.

Stack-0verflow Question:
http://stackoverflow.com/questions/30853744/apache-camel-and-cxf-jax-rs-rest-services-end-point-routing-and-proxy-server

Thanks,
Bhavesh

On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <mi...@gmail.com>
wrote:

> Hi All,
>
>
>
> I am new to Apache Camel and trying to solve following problem with
> routing:
>
>
>
> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
> (end-point).
>
>
>
> I have another set of REST Service that is not within same Java Process it
> is in (python or any other Process but on same host).
>
>
>
>
>
> We have unified port to access both services,  for example,
>
>
>
> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
> Services)}
>
>
>
>
>
>      <cxf:rsServer id="javaRestServer" address="
> http://localhost:9090/java_api"
>
>          loggingFeatureEnabled="true"
>
>          serviceClass="…." >
>
>          <cxf:providers>
>
>               <ref bean="jaxbProvider" />
>
>               <ref bean="jsonProvider" />
>
>          </cxf:providers>
>
>          <cxf:serviceBeans>
>
>               <ref bean="myService"/>
>
>          </cxf:serviceBeans>
>
>      </cxf:rsServer>
>
>
>
>
>
> The problem with this approach is there is unnecessary http call for Java
> API(java_api) route since it is already locally hosted and we do not want
> to incur HTTP call.
>
>
>
> This has been done to set-up all the CXF context and be able to server
> REST service.
>
>
>
> So, my questions are:
>
>
>
> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
> (direct call) rather then http call for Java API ?
>
> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
> *) gets passed to old Service API ? Since, Java Layer is indeed acting as
> proxy server.
>
>
> Thanks in advance for your help !
>
>
> Thanks,
>
>
>
> Bhavesh
>
>
>

Re: Apache Camel Routing and Apache CXF Rest with Proxy

Posted by Bhavesh Mistry <mi...@gmail.com>.
I just need some help and guidelines with above issue.

Stack-0verflow Question:
http://stackoverflow.com/questions/30853744/apache-camel-and-cxf-jax-rs-rest-services-end-point-routing-and-proxy-server

Thanks,
Bhavesh

On Mon, Jun 15, 2015 at 2:56 PM, Bhavesh Mistry <mi...@gmail.com>
wrote:

> Hi All,
>
>
>
> I am new to Apache Camel and trying to solve following problem with
> routing:
>
>
>
> I have CXF JAX-RS based REST Service implemented and deployed in same JVM
> (end-point).
>
>
>
> I have another set of REST Service that is not within same Java Process it
> is in (python or any other Process but on same host).
>
>
>
>
>
> We have unified port to access both services,  for example,
>
>
>
> Client call ----> HTTP Rest call (*8080*) -----  Camel Route(  if(“/java_api/”
> ---->  to(http://localhost:*9090*) else { to (http://localhost:9091 (OLD
> Services)}
>
>
>
>
>
>      <cxf:rsServer id="javaRestServer" address="
> http://localhost:9090/java_api"
>
>          loggingFeatureEnabled="true"
>
>          serviceClass="…." >
>
>          <cxf:providers>
>
>               <ref bean="jaxbProvider" />
>
>               <ref bean="jsonProvider" />
>
>          </cxf:providers>
>
>          <cxf:serviceBeans>
>
>               <ref bean="myService"/>
>
>          </cxf:serviceBeans>
>
>      </cxf:rsServer>
>
>
>
>
>
> The problem with this approach is there is unnecessary http call for Java
> API(java_api) route since it is already locally hosted and we do not want
> to incur HTTP call.
>
>
>
> This has been done to set-up all the CXF context and be able to server
> REST service.
>
>
>
> So, my questions are:
>
>
>
> 1) 1) Is there any way to setup route to call cxf local binding JAX-RS
> (direct call) rather then http call for Java API ?
>
> 2) 2) How can I configure route such a way so HTTP Proxy headers  (e.g *X-Forwarded-For
> *) gets passed to old Service API ? Since, Java Layer is indeed acting as
> proxy server.
>
>
> Thanks in advance for your help !
>
>
> Thanks,
>
>
>
> Bhavesh
>
>
>