Or use an AtomicInteger or some other pojo to hold the value as a reference. Java is copy by value http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value
On Wed, Apr 13, 2016 at 12:57 PM, Siano, Stephan <stephan.si...@sap.com> wrote: > Hi, > > If you manage to access your variable with a simple expression this should > work (e.g. if a is a static field of YourRouteBuilder class, you might be > able to access it as ${your.package.YourRouteBuilderClass.a}), though I have > never tried that. A processor might be easier. > > Best regards > Stephan > > -----Original Message----- > From: Kasim Sert (Ibtech-Software Infrastructure) > [mailto:kasim.s...@ibtech.com.tr] > Sent: Mittwoch, 13. April 2016 12:08 > To: users@camel.apache.org > Subject: RE: Changing header value > > Hi, > > You mean since its a constant expression it is evaluated at the beginning and > not changed after as far as I understand. So can I do it with simple > expression instead of constant or should I introduce new processor to make it > read current value of variable a. > > Thank you. > > -----Original Message----- > From: Siano, Stephan [mailto:stephan.si...@sap.com] > Sent: Wednesday, April 13, 2016 12:11 PM > To: users@camel.apache.org > Subject: RE: Changing header value > > Hi, > > At the beginning of the route you are setting the header to the value a has > when the route is started (it's a constant expression). In the processor you > are incrementing the value and are then setting the header to the current > value of the variable a, so the route behaves as one would expect. > > Best regards > Stephan > > -----Original Message----- > From: Kasim Sert (Ibtech-Software Infrastructure) > [mailto:kasim.s...@ibtech.com.tr] > Sent: Mittwoch, 13. April 2016 10:52 > To: users@camel.apache.org > Subject: Changing header value > > Hi, > > Can somebody please explain, why header value for starting always remains > same although its changed in processor ? > > Route: > İnt a=1 > from("timer://myTimer2?period=1000") > .setHeader("myheader", constant(a)) > .log("starting...${header[myheader]}") > .process(new Processor() { > @Override > public void process(Exchange exchange) > throws Exception { > a = a+1 ; > > exchange.getIn().setHeader("myheader", constant(a)); > Thread.sleep(10000); > } > }) > .log("ending...${header[myheader]}"); > > > Log produced: > > 2016-04-13 11:45:47,894 [imer://myTimer2] INFO route1 > - starting...1 > 2016-04-13 11:45:57,899 [imer://myTimer2] INFO route1 > - ending...2 > 2016-04-13 11:45:57,900 [imer://myTimer2] INFO route1 > - starting...1 > 2016-04-13 11:46:07,900 [imer://myTimer2] INFO route1 > - ending...3 > 2016-04-13 11:46:07,900 [imer://myTimer2] INFO route1 > - starting...1 > 2016-04-13 11:46:17,901 [imer://myTimer2] INFO route1 > - ending...4 > > > > [Facebook]<http://www.facebook.com/Finansbank> [Twitter] > <http://twitter.com/finansbank> > > [https://www.finansbank.com.tr/Disclaimer/BannerImages.aspx?date=13.04.201611:5100]<https://www.finansbank.com.tr/Disclaimer/Bannerlink.aspx?date=13.04.201611:5100> > > > Bu e-posta'nın içerdiği bilgiler (ekleri dahil olmak üzere) gizlidir. > Onayımız olmaksızın üçüncü kişilere açiklanamaz. Bu mesajın gönderilmek > istendiği kişi değilseniz, lütfen mesajı sisteminizden derhal siliniz. IBTech > A.Ş. bu mesajın içerdiği bilgilerin doğruluğu veya eksiksiz olduğu konusunda > bir garanti vermemektedir. Bu nedenle bilgilerin ne şekilde olursa olsun > içeriğinden, iletilmesinden, alınmasından, saklanmasından sorumlu değildir. > Bu mesajın içeriği yazarına ait olup, IBTech A.Ş.'nin görüşlerini > içermeyebilir. > > The information contained in this e-mail (including any attachments)is > confidential. It must not be disclosed to any person without our authority. > If you are not the intended recipient, please delete it from your system > immediately. IBTech A.S. makes no warranty as to the accuracy or completeness > of any information contained in this message and hereby excludes any > liability of any kind for the information contained therein or for the > information transmission, reception, storage or use of such in any way > whatsoever. Any opinions expressed in this message are those of the author > and may not necessarily reflect the opinions of IBTech A.S. > > > Bu e-posta'nin içerdigi bilgiler (ekleri dahil olmak > üzere) gizlidir. Onayimiz olmaksizin üçüncü kisilere açiklanamaz. Bu mesajin > gönderilmek istendigi kisi degilseniz, lütfen mesaji sisteminizden derhal > siliniz. IBTech A.S. bu mesajin içerdigi bilgilerin dogrulugu veya eksiksiz > oldugu konusunda bir garanti vermemektedir. Bu nedenle bilgilerin ne sekilde > olursa olsun içeriginden, iletilmesinden, alinmasindan, saklanmasindan sorumlu > degildir. Bu mesajin içerigi yazarina ait olup, IBTech A.S.'nin görüslerini > içermeyebilir. > > The information contained in this e-mail (including any > attachments)is confidential. It must not be disclosed to any person without > our > authority. If you are not the intended recipient, please delete it from your > system immediately. IBTech A.S. makes no warranty as to the accuracy or > completeness of any information contained in this message and hereby excludes > any liability of any kind for the information contained therein or for the > information transmission, reception, storage or use of such in any way > whatsoever. Any opinions expressed in this message are those of the author and > may not necessarily reflect the opinions of IBTech > A.S. -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2