Closed regardfs closed 7 years ago
If I properly understand you want a listener for events, in that case can you have a look at: https://github.com/apache/camel/blob/master/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdWatchConsumer.java
@lburgazzoli , thanks a lot!!! I mean monitor etcd key and do sth, like this cmd:/usr/bin/etcdctl exec-watch --recursive /corekube/apiservers -- /opt/bin/echosth.sh
So yes you can look at the example I provided, it use an index to avoid loosing events in between
@lburgazzoli , hi firstly, I am a new greenhand on java, I am a pythoner and goer. I have read all code in the link:https://github.com/apache/camel/blob/master/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdWatchConsumer.java but It seems that it still a one time event for etcdwatch.
/usr/bin/etcdctl exec-watch --recursive /corekube/apiservers -- 1.sh
that means watch on /corekube/apiservers and if sth changed it will run /opt/bin/echosth.sh and continue to watch on next modification.
/ # etcdctl exec-watch --recursive /configurations/gaia/foo -- "1.sh" Mon May 22 15:25:20 UTC 2017: changed Mon May 22 15:25:26 UTC 2017: changed Mon May 22 15:25:30 UTC 2017: changed
When the code starts it invokes the watch method
Then inside the callback, it invokes watch again so it loops.
Yes
Luca Burgazzoli
On Mon, May 22, 2017 at 5:48 PM, Leo.feng notifications@github.com wrote:
@lburgazzoli https://github.com/lburgazzoli you mean this one will start first and trigger watch() in onResponse()?
protected void doStart() throws Exception { super.doStart(); watch(); }
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jurmous/etcd4j/issues/147#issuecomment-303140206, or mute the thread https://github.com/notifications/unsubscribe-auth/AByEhRlaC1Y9bvwsHczrvfiIKka6I7vyks5r8a5qgaJpZM4NiWGt .
@lburgazzoli , Sorry for bothering u again and again, It seems that use start and onResponse together to generate the loop, but I could not comprehend how,so dismay..
@lburgazzoli thanks a lot!!!!
@lburgazzoli last question how to register onResponse?Is this one:
https://github.com/apache/camel/blob/3505e718db48cc0d8be5b47f6c4030c958d93a5f/components/camel-etcd/src/main/java/org/apache/camel/component/etcd/EtcdWatchConsumer.java#L153 Soooooooooo appreciating you patience and explaination!
Yes it is, you need to associate a callback to the promise you get
@lburgazzoli hurray!!! Thanks, I wish u merry Christmas and happy new year :)
For now,I could monitor one time etcd value change and do a reaction with code below:
I want to know does etcd4j Etcdclient support lasting waitForChange function?