You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Johan Haleby <jo...@gmail.com> on 2010/01/14 12:05:08 UTC
Store data be used in other steps in an exchange
Hi,
I have a use-case where I must extract a endpoint uri from an object,
marshal the object to an unknown format and then send the result to the
extracted uri. Is there a built-in way to do this or do I have to manually
persist the extract endpoint and retrieve a dynamic router or something?
Here's some pseudo code describing what I'm looking for:
from("somewhere").extractURIFromConsumedObject().
marshal(encodeToUnknownFormat).to("uriThatWasExtractedFromTheConsumedObject");
Thanks,
/Johan
--
View this message in context: http://old.nabble.com/Store-data-be-used-in-other-steps-in-an-exchange-tp27159537p27159537.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Store data be used in other steps in an exchange
Posted by Johan Haleby <jo...@gmail.com>.
Hi,
I used something similar as your example to solve it. Works great! Thanks!
/Johan
Ashwin Karpe wrote:
>
> Hi Johan,
>
> You can do this in the following way
>
> from("somewhere")
> .process(new Processor() {
> public void process(Exchange exchange) throws Exception {
> String payload = exchange.getIn().getBody(String.class);
> // get URI from payload body and set it in header (optional if
> such a header exists)
> exchange.getIn.setHeader("targetURI",...)
> exchange.getIn().setBody("Changed body");
> }
> })
> .marshal(...) // Not sure what marshalling you need here
> .process(new Processor() {
> public void process(Exchange exchange) throws Exception {
> String payload = exchange.getIn().getBody(String.class);
> String targetURI = exchange.getIn().getHeader("targetURI");
> ProducerTemplate producer = new ProducerTemplate(...);
> Exchange result = producer.send(targetURI , exchange);
> ...
> }
> }).
>
> Cheers,
>
> Ashwin...
>
>
> Johan Haleby wrote:
>>
>> I found out by myself. I simply put the uri in a header and simply pass
>> the header to the recipient list.
>>
>>
>> Johan Haleby wrote:
>>>
>>> Hi,
>>>
>>> I have a use-case where I must extract a endpoint uri from an object,
>>> marshal the object to an unknown format and then send the result to the
>>> extracted uri. Is there a built-in way to do this or do I have to
>>> manually persist the extract endpoint and retrieve a dynamic router or
>>> something? Here's some pseudo code describing what I'm looking for:
>>>
>>> from("somewhere").extractURIFromConsumedObject().
>>> marshal(encodeToUnknownFormat).to("uriThatWasExtractedFromTheConsumedObject");
>>>
>>> Thanks,
>>> /Johan
>>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Store-data-be-used-in-other-steps-in-an-exchange-tp27159537p27166997.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Store data be used in other steps in an exchange
Posted by Ashwin Karpe <as...@progress.com>.
Hi Johan,
You can do this in the following way
from("somewhere")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
// get URI from payload body and set it in header (optional if
such a header exists)
exchange.getIn.setHeader("targetURI",...)
exchange.getIn().setBody("Changed body");
}
})
.marshal(...) // Not sure what marshalling you need here
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String payload = exchange.getIn().getBody(String.class);
String targetURI = exchange.getIn().getHeader("targetURI");
ProducerTemplate producer = new ProducerTemplate(...);
Exchange result = producer.send(targetURI , exchange);
...
}
}).
Cheers,
Ashwin...
Johan Haleby wrote:
>
> I found out by myself. I simply put the uri in a header and simply pass
> the header to the recipient list.
>
>
> Johan Haleby wrote:
>>
>> Hi,
>>
>> I have a use-case where I must extract a endpoint uri from an object,
>> marshal the object to an unknown format and then send the result to the
>> extracted uri. Is there a built-in way to do this or do I have to
>> manually persist the extract endpoint and retrieve a dynamic router or
>> something? Here's some pseudo code describing what I'm looking for:
>>
>> from("somewhere").extractURIFromConsumedObject().
>> marshal(encodeToUnknownFormat).to("uriThatWasExtractedFromTheConsumedObject");
>>
>> Thanks,
>> /Johan
>>
>
>
-----
---
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
---
+1-972-304-9084 (Office)
+1-972-971-1700 (Mobile)
----
Blog: http://opensourceknowledge.blogspot.com/
--
View this message in context: http://old.nabble.com/Store-data-be-used-in-other-steps-in-an-exchange-tp27159537p27166838.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Store data be used in other steps in an exchange
Posted by Johan Haleby <jo...@gmail.com>.
I found out by myself. I simply put the uri in a header and simply pass the
header to the recipient list.
Johan Haleby wrote:
>
> Hi,
>
> I have a use-case where I must extract a endpoint uri from an object,
> marshal the object to an unknown format and then send the result to the
> extracted uri. Is there a built-in way to do this or do I have to manually
> persist the extract endpoint and retrieve a dynamic router or something?
> Here's some pseudo code describing what I'm looking for:
>
> from("somewhere").extractURIFromConsumedObject().
> marshal(encodeToUnknownFormat).to("uriThatWasExtractedFromTheConsumedObject");
>
> Thanks,
> /Johan
>
--
View this message in context: http://old.nabble.com/Store-data-be-used-in-other-steps-in-an-exchange-tp27159537p27160731.html
Sent from the Camel - Users mailing list archive at Nabble.com.