camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Restlet HTTP status and message
Date Fri, 01 Oct 2010 08:27:26 GMT
Hi

Ah looks like an oversight in the restlet component. I have created a
ticket to add the status code and some other details missing
https://issues.apache.org/activemq/browse/CAMEL-3185


On Fri, Oct 1, 2010 at 10:00 AM, mat127 <p3tr.matousek@gmail.com> wrote:
>
> I am afraid the restlet component does not set the HTTP response code
> anywhere. I am using a simple logger to inspect the Exchange instance
> comming from the restlet:
>
>        <bean id="header.logger"
>                 class="ExchangeHeadersInspector" />
>
> where the ExchengeHeadersInspector is coded in Scala:
>
> import org.apache.camel.Exchange
> import se.scalablesolutions.akka.util.Logging
>
> import org.apache.camel.Processor
>
> class ExchangeHeadersInspector extends Processor with Logging {
>
>   def process(exchange: Exchange): Unit = {
>       log.debug("in.headers: %s" format exchange.getIn.getHeaders)
>       log.debug("exchange.properties: %s" format exchange.getProperties)
>       log.debug("exchange.failed: %s" format exchange.isFailed)
>   }
>
> }
>
> As you can see from the log produced by it there is no key
> CamelHttpResponseCode within the exchange.getIn.getHeaders map:
>
> [DEBUG] [2010-09-30 14:57:47,017] [main]
> c.b.i.c.a.l.ExchangeHeadersInspector: in.headers:
> {org.restlet.http.headers=[Server: Apache-Coyote/1.1, Content-Type:
> text/html;charset=utf-8, Content-Length: 1090, Date: Thu, 30 Sep 2010
> 12:57:46 GMT, Connection: close]}
> [DEBUG] [2010-09-30 14:57:47,018] [main]
> c.b.i.c.a.l.ExchangeHeadersInspector: exchange.properties:
> {CamelToEndpoint=http:// ... }
> [DEBUG] [2010-09-30 14:57:47,018] [main]
> c.b.i.c.a.l.ExchangeHeadersInspector: exchange.failed: false
>
> Is it possible that it is stripped down from the Exchange while routing from
> the restlet to my process component?
>
> Anyway I also tried something similar that Claus suggested and inserted some
> validation before the JSON unmarshalling:
>
>                <camel:route>
>            <camel:from uri="direct:rest"/>
>            <camel:to uri="restlet:http://somewhere.net/path/to/rest/api"/>
>            <camel:process ref="header.logger" />
>            <camel:validate>
>                <camel:simple>${header.CamelHttpResponseCode} == 200</camel:simple>
>            </camel:validate>
>            <camel:unmarshal ref="json" />
>                </camel:route>
>
> And even in case of 200 response code I received exception as there is no
> CamelHttpResponseCode key in the headers map:
>
> SEVERE: Failed delivery for exchangeId:
> b71067ad-e305-4762-a4e7-f7baab6dd42d. Exhausted after delivery attempt: 1
> caught: org.apache.camel.processor.validation.PredicateValidationException:
> Validation failed for Predicate[header(CamelHttpResponseCode) == 200].
> Exchange[Message: ... ]
> org.apache.camel.processor.validation.PredicateValidationException:
> Validation failed for Predicate[header(CamelHttpResponseCode) == 200].
> Exchange[Message: ... ]
> ...
>
> Petr
> --
> View this message in context: http://camel.465427.n5.nabble.com/Restlet-HTTP-status-and-message-tp3047023p3068911.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message