Skip to content

Pub/Sub Subscriber.stopAsync() is not asynchronous #3134

@j256

Description

@j256

The javadocs for Subscriber.stopAsync() (really from AbstractApiService) read:

... this initiates a service shutdown and returns immediately.

This does not seem to be how it is implemented in Pub/Sub. The doStop() calls into the MessageDispatcher.stop() then into the MessageWaiter.waitNoMessages(), etc..

Maybe the method name needs to be changed or the functionality updated? What I've had to do outside is to fork a thread that calls stopAsync(), dequeue messages from the receiver queues in other thread(s) so they can be nack'd in a ~spin loop, notice when the subscriber.state() gets to TERMINATED, and then join with the stopping thread.

A simple way to test this is to receive a message, don't ack or nack it reply-consumer, and the call stopAsync().

Maybe I am missing a configuration option or something? Thanks.

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions