ack-watch.asciidoc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. [[java-rest-high-watcher-ack-watch]]
  2. === Ack Watch API
  3. [[java-rest-high-watcher-ack-watch-execution]]
  4. ==== Execution
  5. {xpack-ref}/actions.html#actions-ack-throttle[Acknowledging a watch] enables you
  6. to manually throttle execution of a watch's actions. A watch can be acknowledged
  7. through the following request:
  8. ["source","java",subs="attributes,callouts,macros"]
  9. --------------------------------------------------
  10. include-tagged::{doc-tests}/WatcherDocumentationIT.java[ack-watch-execute]
  11. --------------------------------------------------
  12. <1> The ID of the watch to ack.
  13. <2> An optional list of IDs representing the watch actions that should be acked.
  14. If no action IDs are provided, then all of the watch's actions will be acked.
  15. [[java-rest-high-watcher-ack-watch-response]]
  16. ==== Response
  17. The returned `AckWatchResponse` contains the new status of the requested watch:
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/WatcherDocumentationIT.java[ack-watch-response]
  21. --------------------------------------------------
  22. <1> The status of a specific action that was acked.
  23. <2> The acknowledgement state of the action. If the action was successfully
  24. acked, this state will be equal to `AckStatus.State.ACKED`.
  25. [[java-rest-high-watcher-ack-watch-async]]
  26. ==== Asynchronous Execution
  27. This request can be executed asynchronously:
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests}/WatcherDocumentationIT.java[ack-watch-execute-async]
  31. --------------------------------------------------
  32. <1> The `AckWatchRequest` to execute and the `ActionListener` to use when
  33. the execution completes.
  34. The asynchronous method does not block and returns immediately. Once the request
  35. completes, the `ActionListener` is called back using the `onResponse` method
  36. if the execution successfully completed or using the `onFailure` method if
  37. it failed.
  38. A listener for `AckWatchResponse` can be constructed as follows:
  39. ["source","java",subs="attributes,callouts,macros"]
  40. --------------------------------------------------
  41. include-tagged::{doc-tests}/WatcherDocumentationIT.java[ack-watch-execute-listener]
  42. --------------------------------------------------
  43. <1> Called when the execution is successfully completed. The response is
  44. provided as an argument.
  45. <2> Called in case of failure. The raised exception is provided as an argument.