camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Wein <frank.w...@fau.de>
Subject Re: How to use the InOut (Request-Reply) pattern in combination with REST/Jetty?
Date Mon, 28 Nov 2016 07:51:18 GMT
Hi all,
some additional info/Java code: What I have currently working is some 
code without the ActiveMQ part:

restConfiguration().component("jetty").host("0.0.0.0").port(8080)
                 .dataFormatProperty("prettyPrint", "true")
                 .bindingMode(RestBindingMode.auto);

        rest("/API/").get("/object/{ID}/").to("direct:objectGet");

         from("direct:objectGet")
                  .setExchangePattern(ExchangePattern.InOut)
                  .setHeader(Exchange.HTTP_PATH, simple(
"/Webservice/RESTService/Object/${header.ID}"))
                  .setHeader(Exchange.HTTP_METHOD, simple("GET"))
.to("jetty://http://localhost:8888?bridgeEndpoint=true");

I send my REST request to localhost:8080/object/[ID]/ and get back the 
reply from the other webservice running on localhost:8888.

Now, I want to include an ActiveMQ queue here. Basically the ActiveMQ 
queue should be between the two routes (from/to("direct:objectGet")). 
The first route should send the message to the queue, the second route 
should fetch it, get the response from the other web service and send 
the response back via the queue to the first route. This one should then 
reply to the incoming REST request. Is this possible, if yes, how? My 
attempts at this did not really work.

Regards
Frank


Frank Wein wrote:
> Hi all,
> I have a problem setting up the correct Camel routes in Java for a 
> problem I'm having. I'm still quite new to Camel and ActiveMQ, so 
> please be patient with me :)
>
> What I want to accomplish is the following:
> * Provide a REST (HTTP GET) endpoint with Camel (Jetty) and send the 
> request (message) to an ActiveMQ queue (the ActiveMQ queue is a 
> requirement, probably would be easier without)
> * Consume the message (with a second route?), take some of the 
> parameters from the HTTP URL (so message properties) and send a 
> HTTP/REST request to another REST service.
> * Take the response from the other REST service and send it back to 
> the REST client (from the beginning)


-- 
Frank Wein
Forschungsgruppe Netz
Friedrich-Alexander-Universitaet Erlangen-Nuernberg
Regionales Rechenzentrum Erlangen (RRZE)
Martensstrasse 1, 91058 Erlangen, Germany
Tel. +49 9131/85-29983, Fax +49 9131/302941
frank.wein@fau.de
www.rrze.fau.de



Mime
View raw message