I am using pubsub with Gmail for push notifications.
The pubsub subscription recieves messages as expected.
When I pull the messages however I have noticed that if there are no messages to pull the delay in getting a response is very slow.
If there is at least 1 message to pull then the response is timely
Has anybody else experienced this?
The only fix I can come up with is to leave a message on the queue.
if (credential.RequestAccessTokenAsync(CancellationToken.None).Result)
{
var pubsubSerivce = new Google.Apis.Pubsub.v1beta2.PubsubService(
new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "iLink",
});
PullRequest pr = new PullRequest();
pr.MaxMessages = 100;
PullResponse prs = pubsubSerivce.Projects.Subscriptions.Pull(pr, "projects/vivid-canyon-90023/subscriptions/iLink").Execute();
AcknowledgeRequest ak = new AcknowledgeRequest();
if (prs != null && prs.ReceivedMessages != null)
{
ak.AckIds = new List<string>();
string messageText = "";
foreach (ReceivedMessage rm in prs.ReceivedMessages)
{
ak.AckIds.Add(rm.AckId);
messageText += " | " + rm.Message.Data;
}
pubsubSerivce.Projects.Subscriptions.Acknowledge(ak, "projects/vivid-canyon-90023/subscriptions/iLink").Execute();
Master.setSuccessPrompt("Pulled Total Meesage count of: " + prs.ReceivedMessages.Count + " | Data | " + messageText);
}
else
{
Master.setSuccessPrompt("No Messages to pull");
}
}