I am currently experimenting with the Google Cloud PubSub go library and am consulting the documentation at the same time.
My code checks the behavior of a function PullWaitthat, according to the documentation , does the following:
PullWait retrieves messages from a subscription. If there are not enough messages in the subscription queue, they will be blocked until at least n messages or a timeout arrives, and n cannot be more than 100.
However, my test shows that regardless of the value n, I always get messages mwhere m <= n. Am I missing something?
Excerpt from the code used:
msgs, err := pubsub.PullWait(subCtx, subscriptionName, 50)
if err != nil {
log.Printf("Error when trying to pull messages from subscription: %v", err)
} else {
for _, msg := range msgs {
str := string(msg.Data)
log.Printf("Message [msg-id=%s]: '%v'", msg.ID, str)
if err := pubsub.Ack(ctx, subscriptionName, msg.AckID); err != nil {
log.Printf("Unable to acknowledge message [ack-id=%s]: %v", msg.AckID, err)
}
}
}
And the time queue contained only one message that was returned to me right now:
2015/11/04 11:45:15 [msg-id = 2384294654226]: 'hello world my friend'