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)
From my understanding I'm providing some kind of proxy server (with URL rewriting), which needs to use the InOut pattern in this case. Later I also want to provide other REST operations (e.g. POST) with message body transformations, which again get forwarded to other REST services.
My attempts were something like this (simplified code, more or less; so don't wonder why the {ID} part disappeared):
getContext().addComponent("activemq", ActiveMQComponent.activeMQComponent("tcp://localhost:61616")); restConfiguration().component("jetty").host("localhost").port(8080) .dataFormatProperty("prettyPrint", "true"); rest("/API/").get("/{ID}/").to("direct:getObject"); from("direct:getObject").setExchangePattern(ExchangePattern.InOut).to("activemq:testQueue"); from("activemq:testQueue") .setHeader(Exchange.HTTP_PATH, simple("/getObject/")) .setHeader(Exchange.HTTP_METHOD, simple("GET")) .to("jetty:http://localhost:8888?bridgeEndpoint=true");Probably that's not correct (as I don't really send the REST reply back/store somewhere?), I'm a bit lost how to continue here. I found http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html, but additionally I need to involve the ActiveMQ queue there (and modify the HTTP URL). Maybe I need to get the message out body from the message exchange and store the reply there...?
Best regards Frank
smime.p7s
Description: S/MIME Cryptographic Signature