2 Replies Latest reply on Sep 7, 2015 6:45 AM by ozkin

    Pojo object as argument for Camel route

    ozkin

      Hi, this is perhaps very basic question. Imagine there is a REST binding with a method with multiple parameters. Then there is a POJO class, which combines all these parameters, so that in Java service interface we have only one parameter. Then there is a Camel component, which implements that service interface.

       

      How to access POJO member variables from the Camel route (Java DSL)? If I use ${body} then it just points to the first member variable from the given POJO object, but I would like to be able to have a separate access to each of the variables...

        • 1. Re: Pojo object as argument for Camel route
          ozkin

          Does anyone have any example of a Camel route where ${body} isn't a simple String but rather a Pojo object?

          • 2. Re: Pojo object as argument for Camel route
            ozkin

            As I expected the solution was too simple.. I just had to explore a bit more how to work with the body in a Camel route.

            ${body.fieldName} syntax gives me the required access to the getter methods of Pojo's fields.

            (I just didn't understand why ${body} in my app printed first field value instead of Pojo object's address, as it did in another test app).