Need to use watches for an use key value store consul

I am new to consul. Actually i have usecase where i need to add a watch to particular key in consul keystore, if there i an change to the value for that key consul should notify. I Read about watches in consul, i am still confused if consul supports this kind of behavior. Can anybody point me to an example if this possible.

I think it’s documented very well:

You could execute a script which will be triggered and notifies you:
consul watch -type=key -key=foo/bar/baz /usr/bin/

Yeah correct I went through this document. The issue is I have an Java code which need to do this that code needs some kind of event to act on.

Something like consul writes a file, your Java app is looking for it and reacts if it’s present or content is “x”? Kind of a signal or trigger file?

Something like AWS S3 object notification. Okk one question. does consul have some hash on the key. Like if the value for the key changes the hash for that key changes , something like the value of if-match header in terms of REST