You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Joseph E. Kampf Jr." <jo...@gmail.com> on 2016/03/15 02:07:24 UTC

Re: camel rest route

You configure method is not called every time your route executed. Only once to create the route. If you want some code executed each time to create a new user object, create a processor that executes your user create code and puts the user object in the body of the message. 

Thanks,

Joe

> On Feb 23, 2016, at 11:23 AM, zappee <ar...@gmail.com> wrote:
> 
> Hi,
> 
> Thx for the reply.
> 
> Now I am facing with another strange behavior. I want to fill in my user
> object with random generated data, like this:
> 
> @Override 
> public void configure() throws Exception { 
>    User user = new User(); 
>    user.setFirstName(*Generator.randomFirstName()*);
>    user.setLastName(*Generator.randomLastName()*);
>    *user.setBirthday(new Date());*
> 
>    restConfiguration().component(*"restlet"*) 
>    *.host("localhost").port(8081)* 
>            .bindingMode(RestBindingMode.json) 
>            .dataFormatProperty("prettyPrint", "true"); 
> 
>    rest("/user") 
>            .description("user rest service") 
>            .produces(APPLICATION_JSON_UTF_8) 
>            .get("/hello")
> .outType(User.class).route().routeId("GET@/generate").transform().constant(user).endRest(); 
> }
> 
> 
> But I always get the same values in all fields. For example the birthday
> field is fill in with the current timestamp value during the first rest call
> and same value is displayed later in the next calls:
> 
> First response:
> {
> "id": null,
> "email": null,
> "firstName": "Lindsey",
> "lastName": "Craft",
> "birthday": 1456243732376
> }
> 
> I get the exactly same response if i call my rest in the next 5 mins. How it
> is possible?
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-rest-route-tp5777992p5778136.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: camel rest route

Posted by zappee <ar...@gmail.com>.
Hi,

Thx. for the reply. As you suggested the solution is use processor.





--
View this message in context: http://camel.465427.n5.nabble.com/camel-rest-route-tp5777992p5779126.html
Sent from the Camel - Users mailing list archive at Nabble.com.