As usually, I go my own way :)
I got nice xml using xstream but now I'm trying to extract an element
from it with xpath or xquery.
Should I use process or transform and what is the difference between them?
from("timer://kickoff?period=10000&delay=1").
process(new Processor() {
public void process(Exchange exchange) throws Exception {
ArrayList<HashMap<String, Object>> ds = new
ArrayList<HashMap<String, Object>>();
HashMap<String, Object> h = new HashMap<String, Object>();
h.put("column1", "log body");
ds.add(h);
exchange.getOut().setBody(ds);
}
}).marshal().
xstream().
process(xquery("/list")).
//to("xmpp://vchekan@jabber.org/?password=fotokot&room=room33@conference.jabber.org");
to("xmpp://...........");
Vadim.
Claus Ibsen wrote:
> Hi
>
> As always with Camel there are several/many solutions. Some more elegant.
>
> 1)
> Yes your own processor would do fine. List<Map<String, Object>> is what you
get from JDBC. It's a list of rows, where each row is a Map object with the JDBC column name
as the string key, and the value is the Object.
>
> I would use my own processor to do my transformation to the string that XMPP expects.
>
> 2)
> BTW: There is also the DataFormat solution where you can define your own data format
and serialize/deserialize to/from this format.
> http://activemq.apache.org/camel/data-format.html
>
> 3)
> Or the type converter, then Camel will automatically pick it up and convert it.
>
> @Converter
> public class MyConverter
> @Converter
> public static String convertToString(List<Map<String, Object>> jdbcResult)
{
> ...
> return string
> }
> Then you need a special marker file in the META-INF folder. Its all documented in the
wiki. You can check out camel-core.jar to see this marker file.
>
> But I am not 100% sure the type converter solution will work as the type is a generic.
> http://activemq.apache.org/camel/type-converter.html
>
>
> Feedback on the documentation is highly appreciated. And if the generic type converter
works also.
>
>
>
> Med venlig hilsen
>
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
>
> -----Original Message-----
> From: Vadim Chekan [mailto:vchekan@cox.net]
> Sent: 11. juli 2008 04:18
> To: camel-user@activemq.apache.org
> Subject: Deserializing mesage
>
> Hi all,
> I'm trying to send message from jdbc to xmpp amd I'm getting
> deserialization error. Jdbc creates a message of type
> "ArrayList<HashMap<String, Object>>" but xmpp expects a String.
> Should I add my own Processor or there exist more elegant way to
> transform an object into text or even better into xml?
>
> Vadim.
>
|