On Fri, Oct 16, 2009 at 5:24 PM, llecaroz <louis.leca...@sap.com> wrote:
>
> Hello,
> I am really impresed by the capabilities of Apache Camel.
> I am creating a workflow with a similar route
>                        
> <camel:setBody><camel:constant>1</camel:constant></camel:setBody>
>                                <camel:to uri="sql:select * from rule where 
> ruleId = # order by
> ruleId?dataSourceRef=myDataSource"/>
>                                <camel:setHeader headerName="CamelFileName">
>                                        
> <camel:constant>out.txt</camel:constant>
>                                </camel:setHeader>
>                        <camel:to uri="file://target/data"/>
>
> It works great until trying to save select result :(
>
> because it is an arralist returned, it appears that Apache Camel does not
> have any convert type :(
> I tried also to use jaxb mashall or convertBodyto to convert it before into
> a xml format, but without any success, so I don't know what to do with the
> result without writing a pojo consumer !?
>
> I spent multiple hours on Internet to search for tutorials or other apache
> camel users encountering the same need behavior but no answer :(
>

You can use Java code to transform the payload into a more appropriate format.

You can use a org.apache.camel.Processor or POJO

                        <camel:processRef ref="myTransformProcessor"/>
                        <camel:to uri="file://target/data"/>

<bean id="myTransformProcessor" class="com.mycompany.MyTransformProcessor"/>

public class MyTransformProcessor implements Processor {
 ...
  List data = exchange.getIn().getBody(List.class);
   // use regular java code to transform to a better form
   exchange.getIn().setBody(betterBody);
}



See more at the Message Translator EIP
http://camel.apache.org/message-translator.html

The SQL component returns raw data in a List that is like the sql ResultSet.
You gotta transform that manually to something else using Java code.

Or use some ORM that can map from the database to POJO classes which
are easier to marshal to XML using camel-xstream or JAXB annotations
etc.



>
> Expert help on my question would be appreciate ;)
> Really thx in advance
> Regards
> Louis
>
>
> Caused by: org.apache.camel.InvalidPayloadException: No body available of
> type: java.io.InputStream but has value: [{ruleId=1, syncDir=/essai/1}] of
> type: java.util.ArrayList on: Message: [{ruleId=1, syncDir=/essai/1}].
> Caused by: No type converter available to convert from type:
> java.util.ArrayList to the required type: java.io.InputStream with value
> [{ruleId=1, syncDir=/essai/1}] on the exchange: Exchange[Message:
> [{ruleId=1, syncDir=/essai/1}]]
>
> --
> View this message in context: 
> http://www.nabble.com/How-to-save-a-select-result-from-camel-sql-componnent-to-xml-%28-No-type-converter-available-to-convert-from-type%3A-java.util.ArrayList-issue-%29-tp25927249p25927249.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

Reply via email to