camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Drone42 <gert.ville...@logica.com>
Subject Re: Camel route and message header field mapping
Date Thu, 20 Nov 2008 08:12:01 GMT

That was the missing link for me; Camel messages are not (necesarrily) WSDL
messages as servicemix. 

I can thus chose to a) transmit XML formatted messages and then use Xath to
filter, or b) I can transmit java objects and use other filtering
mechanisms.






Claus Ibsen-2 wrote:
> 
> Hi
> 
> Apache Camel doesn't use XML as payload, so the Account is an java object.
> 
> So if you want to filter you can either
> a) marshal to XML and do the filter and unmarshal from XML to Object
> (eg using xstream)
> b) using something else than xpath for the filter test (predicate)
> 
> Ad a)
> See the xstream DataFormat
> http://activemq.apache.org/camel/data-format.html
> 
> Ad b)
> Instead of xpath you can use
> - Scripting languages such as OGNL, EL, Groovy, JavaScript
> http://activemq.apache.org/camel/languages.html
> 
> - Invoking a bean
> http://activemq.apache.org/camel/bean-language.html
> 
> 
> from("foo:start").filter().bean(MyFilterOnlyJamesBean.class).to(ibatis:InsertAccount);
> 
> public class MyFilterOnlyJamesBean {
> 
>   public boolean isOnlyJames(Account account) {
>      return account.getFirstName().equals("James");
>   }
> 
> }
> 
> 
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
> 
> 
> 
> On Wed, Nov 19, 2008 at 10:55 PM, Drone42 <gert.villemos@logica.com>
> wrote:
>>
>> I'm trying to create a Camel route with an iBATIS SU for storage of data,
>> i.e.
>>
>> MyApp -> MessageFilter SU -> iBATIS SU
>>
>> I dont understand how the POJO created in MyApp is mapped to message
>> header
>> fields in a message transfered through a Camel route and finally to
>> identifiers in the SQL query definition of iBATIS. This is likely a
>> general
>> problem due to my missing understanding of Camel.
>>
>> I have gone through the Camel iBATIS test program. It creates an Account,
>> configures it and send it to the iBATIS endpoint. That I understand. But
>> what when I have another Camel SU in between? How can I filter on the
>> 'Account' instance created by MyApp in the MessageFilter? Which fields
>> are
>> available in the message header? All? Will each attribute in the POJO be
>> mapped to a separate message header field, i.e. if the Account class is
>> defined as
>>
>> public class Account {
>>    private int id;
>>    private String firstName;
>>    private String lastName;
>>    private String emailAddress;
>> ...
>>
>> Will each of these fields then be available in the message header so that
>> I
>> can configure the filter route as
>>
>> from("foo:start").filter().xpath("/Account[@firstName='James']").to(ibatis:InsertAccount);
>> --
>> View this message in context:
>> http://www.nabble.com/Camel-route-and-message-header-field-mapping-tp20590082s22882p20590082.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Camel-route-and-message-header-field-mapping-tp20590082s22882p20596745.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message