I'm using google pubsub to fetch messages synchronously
com.google.pubsub.v1.PullRequest.Builder pullRequestBuilder = PullRequest.newBuilder().setSubscription(subscriptionName).setReturnImmediately(returnImmediately);
if (maxMessages != 0) {
pullRequestBuilder.setMaxMessages(maxMessages);
}
PullRequest pullRequest = pullRequestBuilder.build();
PullResponse pullResponse = (PullResponse)this.subscriber.pullCallable().call(pullRequest);
return pullResponse.getReceivedMessagesList();
I saw in the documentation:
setMaxMessages
public PullRequest setMaxMessages(java.lang.Integer maxMessages)
The maximum number of messages returned for this request. The Pub/Sub system may return fewer than the number specified.
Parameters:
maxMessages - maxMessages or null for none
In my code I pass MAX_INT to avoid any max messages limitation
but I see my java code fetches messages one by one.
What is the right way to skip the max limit?
How can I know it's not just a pub-sub bug?
I sometimes get 0 messages even though there are some in the pubsub.