camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: How extract message body and use later on in route for endpoint?
Date Wed, 20 May 2009 05:01:59 GMT
Hi Dan,

This is a known issue[1], we fixed this issue in camel 1.6.1 and coming
up Camel 2.0-m2.
[1] https://issues.apache.org/activemq/browse/CAMEL-1516

Willem

Dan Haywood wrote:
> Thanks for that Claus.
> 
> I've now got:
> 
> private static final String HOST_URI = "http://localhost:7070";
> 
> from("direct:getEmployee")
> .to("restlet:" + HOST_URI + "/services")
> .process(new Processor() {
>     public void process(Exchange exchange) throws Exception {
>         String resourcePath = ... xpath to obtain the resource path from
> exchange.getIn().getBody()
>         message.setBody(resourcePath);
>         exchange.setOut(message);
>     }
> }).recipientList(new ExpressionAdapter(){
>     public Object evaluate(Exchange exchange) {
> 	return "restlet:" + HOST_URI + exchange.getIn().getBody();
>     }
> });
> 
> This second restlet call fails, with a nullpointerexception.  It seems that
> the org.restlet.Restlet is instantiated with the default constructor.  For
> the first successful call the Restlet#init() method is called, so its
> context is setup correctly.  But for the second restlet call #init() doesn't
> seem to get called.
> 
> This ultimately triggers the NPE in
> com.neolios.restlet.http.HttpConverter#addAdditionalHeaders, trying to get a
> Logger from this context object, but it is passed in from RestletComponent
> which I imagine wraps the Restlet.
> 
> So I'm wondering I wonder if the dynamic creation of the recipientList is
> what's ultimately responsible for this failure to call #init()?
> 
> Any clues?  This is Camel 2.0-M1 against Restlet 1.1.1.
> 
> Dan
> 
> 
> 
> Claus Ibsen-2 wrote:
>> Hi
>>
>> You can use the dynamic recipient EIP to construct the URI
>> dynamiically for the receiver.
>> See:
>> http://camel.apache.org/recipient-list.html
>>
>>
>>
>> On Tue, May 19, 2009 at 10:37 AM, Dan Haywood
>> <dan@haywood-associates.co.uk> wrote:
>>> Newbie question, so apologies if it's a dumb one.
>>>
>>> I have an existing RESTful web service that I want to wrap in a
>>> CamelContext.  This service returns XHTML which I want to parse for  's,
>>> in
>>> other words to "walk the graph".
>>>
>>> The first call is to http://localhost:7070/services, returns some XML.  I
>>> can write a processor to fetch out (using XPath) the   I want.  For
>>> example
>>> "/object/OID:123"
>>>
>>> How then do I manufacture the next output, to
>>> http://localhost:7070/object/OID:123 ?
>>>
>>> The code I have currently is:
>>>
>>> from("direct:restfulin")
>>> .to("restlet:" + HOST_URI + "/services")
>>> .process(new Processor() {
>>>  public void process(Exchange exchange) throws Exception {
>>>     String resourcePath = ... xpath to obtain the resource path from
>>> exchange.getIn().getBody()
>>>     message.setBody(resourcePath);
>>>     exchange.setOut(message);
>>>  }
>>> }.to("restlet:" + HOST_URI + /* .... HOW CAN I READ message.getBody()
>>> HERE
>>> */ )
>>> );
>>>
>>> I understand that I can't actually use a ToDefinition but will need to
>>> attach some other sort of SendDefinition or interceptor or something.  I
>>> think I need away to resolve the endpoint *after* having been handed the
>>> object to exchange (a sort of FutureEndpoint?)
>>>
>>> Hope that makes sense,
>>> Thanks
>>> Dan
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-extract-message-body-and-use-later-on-in-route-for-endpoint--tp23612034p23612034.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>> -- 
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
> 


Mime
View raw message