From 92497059406385ea47b2bb7b6dd7340b1cd2900d Mon Sep 17 00:00:00 2001 From: Andrew Carbonetto Date: Sun, 30 Jun 2024 12:16:29 -0700 Subject: [PATCH] Add examples Signed-off-by: Andrew Carbonetto --- .../api/commands/StreamBaseCommands.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java b/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java index 959ba31fa5..58066619e8 100644 --- a/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java +++ b/java/client/src/main/java/glide/api/commands/StreamBaseCommands.java @@ -687,6 +687,16 @@ CompletableFuture xpending( * {"entryId": ["entry", "data"], ...} that are claimed by the consumer. * @example *
+     * // read messages from streamId for consumer1
+     * var readResult = client.xreadgroup(Map.of("mystream", entryId), "mygroup", "consumer1").get();
+     * // assign unclaimed messages to consumer2
+     * Map results = client.xclaim("mystream", "mygroup", "consumer2", 0L, new String[] {entryId}).get();
+     *  for (String key: results.keySet()) {
+     *      System.out.println(key);
+     *      for (int i=0; i
      */
     CompletableFuture> xclaim(
@@ -704,6 +714,18 @@ CompletableFuture> xclaim(
      * @param options Stream claim options {@link StreamClaimOptions}.
      * @return A Map of message entries with the format 
      *     {"entryId": ["entry", "data"], ...} that are claimed by the consumer.
+     * @example
+     *     
+     * // assign (force) unread and unclaimed messages to consumer2
+     * StreamClaimOptions options = StreamClaimOptions.builder().force().build()
+     * Map results = client.xclaim("mystream", "mygroup", "consumer2", 0L, new String[] {entryId}, options).get();
+     *  for (String key: results.keySet()) {
+     *      System.out.println(key);
+     *      for (int i=0; i
      */
     CompletableFuture> xclaim(
             String key,
@@ -724,6 +746,16 @@ CompletableFuture> xclaim(
      * @param minIdleTime The minimum idle time for the message to be claimed.
      * @param ids An array of entry ids.
      * @return An array of message ids claimed by the consumer.
+     * @example
+     *     
+     * // read messages from streamId for consumer1
+     * var readResult = client.xreadgroup(Map.of("mystream", entryId), "mygroup", "consumer1").get();
+     * // assign unclaimed messages to consumer2
+     * Map results = client.xclaimJustId("mystream", "mygroup", "consumer2", 0L, new String[] {entryId}).get();
+     *  for (String key: results.keySet()) {
+     *      System.out.println(key);
+     * }
+     * 
*/ CompletableFuture xclaimJustId( String key, String group, String consumer, long minIdleTime, String[] ids); @@ -740,6 +772,14 @@ CompletableFuture xclaimJustId( * @param ids An array of entry ids. * @param options Stream claim options {@link StreamClaimOptions}. * @return An array of message ids claimed by the consumer. + * @example + *
+     * // assign (force) unread and unclaimed messages to consumer2
+     * StreamClaimOptions options = StreamClaimOptions.builder().force().build()
+     * Map results = client.xclaimJustId("mystream", "mygroup", "consumer2", 0L, new String[] {entryId}, options).get();
+     *  for (String key: results.keySet()) {
+     *      System.out.println(key);
+     * }
      */
     CompletableFuture xclaimJustId(
             String key,