Skip to content

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jun 30, 2024
1 parent 73d1a1a commit 9249705
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,16 @@ CompletableFuture<Object[][]> xpending(
* {"entryId": ["entry", "data"], ...}</code> that are claimed by the consumer.
* @example
* <pre>
* // read messages from streamId for consumer1
* var readResult = client.xreadgroup(Map.of("mystream", entryId), "mygroup", "consumer1").get();
* // assign unclaimed messages to consumer2
* Map<String, String[]> 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<results.get(key).length+1; i=i+2) {
* System.out.println(" {" + results.get(key)[i] + ":" + results.get(key)[i+1] + "}");
* }
* }
* </pre>
*/
CompletableFuture<Map<String, String[]>> xclaim(
Expand All @@ -704,6 +714,18 @@ CompletableFuture<Map<String, String[]>> xclaim(
* @param options Stream claim options {@link StreamClaimOptions}.
* @return A <code>Map</code> of message entries with the format <code>
* {"entryId": ["entry", "data"], ...}</code> that are claimed by the consumer.
* @example
* <pre>
* // assign (force) unread and unclaimed messages to consumer2
* StreamClaimOptions options = StreamClaimOptions.builder().force().build()
* Map<String, String[]> 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<results.get(key).length+1; i=i+2) {
* System.out.println(" {" + results.get(key)[i] + ":" + results.get(key)[i+1] + "}");
* }
* }
* </pre>
*/
CompletableFuture<Map<String, String[]>> xclaim(
String key,
Expand All @@ -724,6 +746,16 @@ CompletableFuture<Map<String, String[]>> xclaim(
* @param minIdleTime The minimum idle time for the message to be claimed.
* @param ids An array of entry ids.
* @return An <code>array</code> of message ids claimed by the consumer.
* @example
* <pre>
* // read messages from streamId for consumer1
* var readResult = client.xreadgroup(Map.of("mystream", entryId), "mygroup", "consumer1").get();
* // assign unclaimed messages to consumer2
* Map<String, String[]> results = client.xclaimJustId("mystream", "mygroup", "consumer2", 0L, new String[] {entryId}).get();
* for (String key: results.keySet()) {
* System.out.println(key);
* }
* </pre>
*/
CompletableFuture<String[]> xclaimJustId(
String key, String group, String consumer, long minIdleTime, String[] ids);
Expand All @@ -740,6 +772,14 @@ CompletableFuture<String[]> xclaimJustId(
* @param ids An array of entry ids.
* @param options Stream claim options {@link StreamClaimOptions}.
* @return An <code>array</code> of message ids claimed by the consumer.
* @example
* <pre>
* // assign (force) unread and unclaimed messages to consumer2
* StreamClaimOptions options = StreamClaimOptions.builder().force().build()
* Map<String, String[]> results = client.xclaimJustId("mystream", "mygroup", "consumer2", 0L, new String[] {entryId}, options).get();
* for (String key: results.keySet()) {
* System.out.println(key);
* }
*/
CompletableFuture<String[]> xclaimJustId(
String key,
Expand Down

0 comments on commit 9249705

Please sign in to comment.