3 Replies Latest reply on Apr 14, 2009 2:00 AM by davsclaus

    Camel - WARNING

    fouquet.f

      Hi ,

       

      I have I stange problem with camel SU

       

      When I start the activity by a timer there is no problem

      But when I call it from An http consumer from another SU I have warning

      19:00:58,145 | WARN  | seda:request thread:22 | JbiBinding               | he.servicemix.camel.JbiBinding   68 | Unable to convert message body of type class java.util.ArrayList into an XML Source

       

       

      After a lot of warning ( the same nomber of the splitter part ) the result is correct and passe to the other endpoint

       

       

       

      hier is my code camel

       

       

       

      Thanks by advance for your help

       

       

      from("jbi:service:http://dev.c.com/dam/ComEntPojoReceptionTrigger")
      .to("seda:request")
      ;
      from("seda:request")
      //from("timer://tutorial?fixedRate=true&delay=10000&period=20000")
      .setBody(constant("select * from table"))
      .to("jdbc:poseidonDB")
      .splitter(body(),true)
      .process(processResult)
      .to("jbi:service:http://dev.c.com/dam/PivotReceptionJMSProvide")
      .to("mock:result")
      .transform(constant("<ack/>"))
      //.clearOutput()
      ;

       

       

       

       

        • 1. Re: Camel - WARNING
          davsclaus

          When you send data back to the JBI endpoint with

          to("jbi:service:http://dev.c.com/dam/PivotReceptionJMSProvide")

           

          You should make sure the data is XML based. So for instance the process(processResult) should set the body in the exchange as XML based.

          • 2. Re: Camel - WARNING
            fouquet.f

            Hi

            Thanks for your help, I'm very happy to found reply to my problem so quickly on this forum.

             

            So I'm agree to you, the message body must be in XML format, but I think that I have made that correctly. I send who my process methode to check . By the way after 30 secondes of warning the XML bases messages build by the process methode are send and receve on the next JMS JBI endpoint so the body is correctly.

             

             

            Hier is my process methode , strangly it  work very well when camel is initiate by internal timer ,

            and there is warning only when camel is initiate by an http binding component.

            In the two case the input MEP is in-only.

             

            Any other idea ?

            Thanks by advance

             

             

                 private Processor processResult = new Processor() {

             

                      private Element mapping(HashMap res,String newelem,String oldelem){

                           Element newelement = new Element(newelem);

                           newelement.setText(res.get("NUMERO").toString());

                           return newelement;

                      }

                       

                      public void process(Exchange exchange) throws Exception {

                                Message in = exchange.getIn();

                                HashMap<String, Object> res = in.getBody(HashMap.class);

                                Element racine = new Element("naf");

                                org.jdom.Document document = new org.jdom.Document(racine);

                                racine.addContent(mapping(res,"ti","NUMERO"));

                                racine.addContent(mapping(res,"lo","LONGITUDE"));

                                racine.addContent(mapping(res,"la","LATITUDE"));

                                racine.addContent(mapping(res,"hour","HOUR"));

                                racine.addContent(mapping(res,"opsat","CODE"));

                                XMLOutputter serializer = new XMLOutputter();

                            String msg = serializer.outputString(document);

                                exchange.getOut(true).setBody(msg, String.class);

                      }

             

                 };

            • 3. Re: Camel - WARNING
              davsclaus

              Hi

               

              I am a bit puzzled where the java.util.List comes into the picture? You processor set the body as a plain String that is XML based.

               

              Can you try setting the body without the type convertions

              exchange.getOut(true).setBody(msg);

               

              Also you can enable the tracer in Camel that dumps the message structure to help us see where the java.util.List comes into play

               

              See about tracer here:

              http://camel.apache.org/tracer.html

               

              Basically adding this code to the route builder:

              getContext().addInterceptStrategy(new Tracer());