camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph E. Kampf Jr." <joseph.ka...@gmail.com>
Subject Re: camel rest route
Date Tue, 15 Mar 2016 01:07:24 GMT
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 <arnold.somogyi@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.

Mime
View raw message