-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add Subscriber snippet #1613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Subscriber snippet #1613
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? |
lesv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tests?
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
lesv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add the comment. -- Thanks.
@jabubake FYI
| 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).
The snippet is very long, but the shortest I can make it without loosing
details.