Skip to content

Commit

Permalink
Fix Transaction tests; update examples
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
  • Loading branch information
acarbonetto committed Jun 30, 2024
1 parent 2b9f3a5 commit 00c790f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -684,17 +684,17 @@ CompletableFuture<Object[][]> xpending(
* @param minIdleTime The minimum idle time for the message to be claimed.
* @param ids A array of entry ids.
* @return A <code>Map</code> of message entries with the format <code>
* {"entryId": ["entry", "data"], ...}</code> that are claimed by the consumer.
* {"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();
* 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] + "}");
* for (String[] entry: results.get(key)) {
* System.out.printf("{%s=%s}%n", entry[0], entry[1]);
* }
* }
* </pre>
Expand All @@ -713,16 +713,16 @@ CompletableFuture<Map<String, String[][]>> xclaim(
* @param ids An array of entry ids.
* @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.
* {"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] + "}");
* for (String[] entry: results.get(key)) {
* System.out.printf("{%s=%s}%n", entry[0], entry[1]);
* }
* }
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,9 @@ private static Object[] streamCommands(BaseTransaction<?> transaction) {
streamKey1,
Map.of()), // xreadgroup(Map.of(streamKey1, ">"), groupName1, consumer1, options);
Map.of(), // xclaim(streamKey1, groupName1, consumer1, 0L, new String[] {"0-1"})
Map.of("0-3", new String[] {"field3", "value3"}), // xclaim(streamKey1, ..., {"0-3"}, options)
Map.of(
"0-3",
new String[][] {{"field3", "value3"}}), // xclaim(streamKey1, ..., {"0-3"}, options)
new String[] {"0-3"}, // xclaimJustId(streamKey1, ..., new String[] {"0-3"})
new String[0], // xclaimJustId(streamKey1, ..., new String[] {"0-4"}, options)
new Object[] {
Expand Down

0 comments on commit 00c790f

Please sign in to comment.