-
1. Re: http component-setheader-previousexchange
davsclaus Jan 16, 2011 4:48 AM (in response to feor58_gfericsan)Use a bean or processor to store the previous timestamp, so you have it handy when the next exchange arrives.
Then all logic for handling that is in the bean / processor and you dont clutter your DSL.
from http
process(new TimestampProcessor())
to http
-
2. Re: http component-setheader-previousexchange
davsclaus Jan 16, 2011 4:49 AM (in response to davsclaus)And mind that the processor / bean is statefull (keep the previous timestamp around) so you may want to synchronize access to it if that really matters.
-
3. Re: http component-setheader-previousexchange
feor58_gfericsan Jan 16, 2011 12:59 PM (in response to davsclaus)Very useful info, thanks. But i am newbie so i don't understand exactly. Would you describe in a bit more detailed? Where is the from timer components?
And is it impossible without Java code?
Thanks.
-
4. Re: http component-setheader-previousexchange
davsclaus Jan 17, 2011 2:02 AM (in response to feor58_gfericsan)Yes its impossible without Java code, or in other words much harder.
You need to store the previous timestamp in memory somewhere. They easy part is just to use java code for it like a java bean.
For example something like this
public class TimestampProcessor implements Processor { private long previous; public void process(Exchange exchange) throws Exception { long now = System.currentTimeInMillis(); if (previous == null) { // this is the first time, do something here } else { // we have the previous timestamp do something else } // update timestamp previous = now; }
-
5. Re: http component-setheader-previousexchange
feor58_gfericsan Jan 28, 2011 2:55 AM (in response to davsclaus)hi Claus,
thanks for your help but my problem is a bit other. I have to include the timestamp parameter from the previous exchange's body into my current http request, then to process the current response. (When my reuqest don't have timestamp parameter then the response the full file, and when my request have timestamp parameter then only the changes are in the result since previous timestamp.)
from(timer).
to(http://x/y.xml?timestamp=???) (The content of y.xml change continually.)
...
The http response (y,xml)
In the first request must not be timestamp parameter.
I think i can't to resolve this situation with your previous tip.
-
6. Re: http component-setheader-previousexchange
davsclaus Jan 28, 2011 6:52 AM (in response to feor58_gfericsan)See the recipient list EIP pattern where you can define a dynamic endpoint uri to invoke in a route.