Hi,
thanks for the link, unfortunately it still doesn't seem to work. The Exchange 
does not receive a reply message:
"org.apache.camel.ExchangeTimedOutException: The OUT message was not received 
within: 20000 millis due reply message with correlationID: 
[...]-33309-1480438574020-0-3 not received on destination: 
temp-queue://ID:[...]-35217-1480438579489-1:1:1. 
Exchange[ID-[...]-33309-1480438574020-0-1]"

The incoming messages on the ActiveMQ queue from the REST endpoint end up in 
the dead-letter queue:
dlqDeliveryFailureCause         java.lang.Throwable: Message Expired. 
Expiration:1480439266246

I tried quite a few things (inOut at different position in the route 
description, getIn, getOut, shared queue, ...), but nothing seems to work 
(always timeout waiting for the reply). Is it possible at all what I want to 
accomplish (reminder: Jetty REST endpoint passes message to queue, other route 
fetches from queue, modifies message and the original endpoint should reply 
with modified message).

Is there a mistake in my current code?

 Processor resultProcessor = new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                    exchange.getIn().setBody( "response");
                return;
            }
        };
      
        getContext().addComponent("activemq", 
ActiveMQComponent.activeMQComponent("tcp://localhost:61616"));

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

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

        from("direct:objectGet").to(ExchangePattern.InOut, 
"activemq:test").process(resultProcessor).to("activemq:test");


Is my "to("activemq:test")" not the correct way to send back the modified 
message to the producer? Actually I thought the message exchange will 
automatically take care of sending back to the modified message body to the 
producer (doesn't seem to make a difference here anyway).


Thanks for any suggestions!

Frank

________________________________________
Von: Quinn Stevenson [qu...@pronoia-solutions.com]
Gesendet: Montag, 28. November 2016 17:35
An: users@camel.apache.org
Betreff: Re: How to use the InOut (Request-Reply) pattern in combination with 
REST/Jetty?

Yes - this is possible.  Look at "Request-Replyā€¯ in the JMS docs ( 
http://camel.apache.org/jms.html <http://camel.apache.org/jms.html> ).


> On Nov 28, 2016, at 12:51 AM, Frank Wein <frank.w...@fau.de> wrote:
>
> 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

Reply via email to