add Subscriber snippet#1613
add Subscriber snippet#1613pongad merged 6 commits intogoogleapis:masterfrom pongad:subscriber-snippet
Conversation
The snippet is very long, but the shortest I can make it without loosing details.
|
Changes Unknown when pulling 5ee8bd3 on pongad:subscriber-snippet into ** on GoogleCloudPlatform:master**. |
|
We shouldn't need locking for a simple example - how can we simplify this? |
|
It does seem overly complex and the locks shouldn't be needed in typical usage. You really only need them if you are trying to run everything on the main thread, instead of thinking threaded and async. |
| if (pendingReceives.decrementAndGet() != 0) { | ||
| return; | ||
| } | ||
| lock.lock(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Changes Unknown when pulling 5ee8bd3 on pongad:subscriber-snippet into ** on GoogleCloudPlatform:master**. |
This should be merged after #205 so that `SettableRpcFuture` could be used to address googleapis/google-cloud-java#1613
|
@lesv @garrettjonesgoogle PTAL. I'll add the tests for both Subscriber and Publisher in one go. They kind of belong in the same test anyway. |
| * if (pendingReceives.decrementAndGet() != 0) { | ||
| * return; | ||
| * } | ||
| * lock.lock(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@garrettjonesgoogle My mistake, PTAL |
|
LGTM with the understanding that tests will come next |
|
@lesv PTAL |
| }); | ||
| subscriber.startAsync(); | ||
|
|
||
| done.get(10, TimeUnit.MINUTES); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| System.out.println("got message: " + message); | ||
| consumer.accept(AckReply.ACK, null); | ||
| if (pendingReceives.decrementAndGet() == 0) { | ||
| done.set(null); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
lesv
left a comment
There was a problem hiding this comment.
Let's separate support from the action of the API.
|
@lesv I think the updated snippets should do what you want. I think it gives us just enough room to properly test the samples too. |
| MessageReceiver receiver = new MessageReceiver() { | ||
| public void receiveMessage(final PubsubMessage message, final AckReplyConsumer consumer) { | ||
| if (blockingQueue.offer(message)) { | ||
| consumer.accept(AckReply.ACK, null); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@lesv Thank you for the rigorous code review. I'll wait for Travis, then merge this. |
🤖 I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
🤖 I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
…v6.67.0 (googleapis#1613) [](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-spanner-bom](https://togithub.com/googleapis/java-spanner) | `6.66.0` -> `6.67.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>googleapis/java-spanner (com.google.cloud:google-cloud-spanner-bom)</summary> ### [`v6.67.0`](https://togithub.com/googleapis/java-spanner/blob/HEAD/CHANGELOG.md#6670-2024-05-22) [Compare Source](https://togithub.com/googleapis/java-spanner/compare/v6.66.0...v6.67.0) ##### Features - Add tracing for batchUpdate, executeUpdate, and connections ([#&googleapis#8203;3097](https://togithub.com/googleapis/java-spanner/issues/3097)) ([45cdcfc](https://togithub.com/googleapis/java-spanner/commit/45cdcfcde02aa7976b017a90f81c2ccd28658c8f)) ##### Performance Improvements - Minor optimizations to the standard query path ([#&googleapis#8203;3101](https://togithub.com/googleapis/java-spanner/issues/3101)) ([ec820a1](https://togithub.com/googleapis/java-spanner/commit/ec820a16e2b3cb1a12a15231491b75cd73afaa13)) ##### Dependencies - Update dependency com.google.cloud:google-cloud-monitoring to v3.44.0 ([#&googleapis#8203;3099](https://togithub.com/googleapis/java-spanner/issues/3099)) ([da44e93](https://togithub.com/googleapis/java-spanner/commit/da44e932a39ac0124b63914f8ea926998c10ea2e)) - Update dependency com.google.cloud:sdk-platform-java-config to v3.30.1 ([#&googleapis#8203;3116](https://togithub.com/googleapis/java-spanner/issues/3116)) ([d205a73](https://togithub.com/googleapis/java-spanner/commit/d205a73714786a609673012b771e7a0722b3e1f2)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/java-spanner-jdbc). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=-->
🤖 I have created a release *beep* *boop* --- ## [2.18.1](https://togithub.com/googleapis/java-spanner-jdbc/compare/v2.18.0...v2.18.1) (2024-05-22) ### Dependencies * Remove open-telemetry dependency import ([googleapis#1608](https://togithub.com/googleapis/java-spanner-jdbc/issues/1608)) ([b567d7a](https://togithub.com/googleapis/java-spanner-jdbc/commit/b567d7a61dbce3e2e2542b85a1889f463426446a)) * Update dependency com.google.cloud:google-cloud-spanner-bom to v6.67.0 ([googleapis#1613](https://togithub.com/googleapis/java-spanner-jdbc/issues/1613)) ([64a72d4](https://togithub.com/googleapis/java-spanner-jdbc/commit/64a72d42ab577e8e32335422d4bea23bbdc60815)) * Update dependency com.google.cloud:sdk-platform-java-config to v3.30.1 ([googleapis#1609](https://togithub.com/googleapis/java-spanner-jdbc/issues/1609)) ([389e174](https://togithub.com/googleapis/java-spanner-jdbc/commit/389e174c8d4a9a3ebebfd233978b793b55b537d8)) * Update dependency io.opentelemetry:opentelemetry-bom to v1.38.0 ([googleapis#1606](https://togithub.com/googleapis/java-spanner-jdbc/issues/1606)) ([6a6b912](https://togithub.com/googleapis/java-spanner-jdbc/commit/6a6b91223b855972659108bc479c226b8b60ebea)) * Update dependency org.springframework.data:spring-data-bom to v2023.1.6 ([googleapis#1610](https://togithub.com/googleapis/java-spanner-jdbc/issues/1610)) ([2da6a4c](https://togithub.com/googleapis/java-spanner-jdbc/commit/2da6a4c8cfa0b947a7fe4bab91bd56d9b1427d1a)) * Update dependency org.springframework.data:spring-data-bom to v2024 ([googleapis#1611](https://togithub.com/googleapis/java-spanner-jdbc/issues/1611)) ([abc482b](https://togithub.com/googleapis/java-spanner-jdbc/commit/abc482b790e7013067aa2d6cf2816cd78e9e1f34)) * Update dependency org.testcontainers:testcontainers to v1.19.8 ([googleapis#1604](https://togithub.com/googleapis/java-spanner-jdbc/issues/1604)) ([dd2b60f](https://togithub.com/googleapis/java-spanner-jdbc/commit/dd2b60f3effe8bafa7bef81c626fde6f41f0d5e3)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
The snippet is very long, but the shortest I can make it without loosing
details.