camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glattfelder, Beat " <beat.glattfel...@credit-suisse.com>
Subject Java DSL question
Date Tue, 20 May 2014 11:36:46 GMT
Hi Camel Riders

I am back with a simple question I found to tough to answer myself: How do I access the message
body in a typesafe manner like in the TODO comment below? Obviously implementing a processor
works fine, but make things harder to read.

Thanks for advising,
Beat

                                                                              from("direct:start-profile-pics")
                                                                                         
                    .to("sql:select * from cwd_user where active='T' and directory_id=76644354?dataSource=confDB")
                                                                                         
                    .split(body())
                                                                                         
                    // TODO: setHeader("uid", bodyAsType(Map.class).get("username"));
                                                                                         
                    .process(new Processor() {

                                                                                         
                                   @Override
                                                                                         
                                   public void process(Exchange exchange)
                                                                                         
                                                                   throws Exception {
                                                                                         
                                                   Message msg = exchange.getIn();
                                                                                         
                                                   msg.setHeader("uid", msg.getBody(Map.class)
                                                                                         
                                                                                  .get("user_name"));
                                                                                         
                                                   msg.setHeader(Exchange.HTTP_PATH, "avatar/"
+ msg.getBody(Map.class)
                                                                                         
                                                                                  .get("user_name"));

                                                                                         
                                   }
                                                                                         
                    })
                                                                                         
                    .setBody(constant(null))
                                                                                         
                    .to("http4://unity-uat.apps.csintra.net/")
                                                                                         
                    .bean(applicationContext
                                                                                         
                                                   .getBean("confluenceClient"),
                                                                                         
                                                   "updateProfilePic");

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message