Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public CallSettings GetPullSetting()
- {
- CallTiming timing = CallTiming.FromRetry(new RetrySettings(
- retryBackoff: new BackoffSettings(new TimeSpan(0, 0, 0, 0, 50), new TimeSpan(0, 0, 5), 1),
- timeoutBackoff: new BackoffSettings(new TimeSpan(0, 0, 0, 18, 0), new TimeSpan(0, 0, 20), 1),
- totalExpiration: Google.Api.Gax.Expiration.FromTimeout(TimeSpan.FromMilliseconds(600000))));
- return CallSettings.FromCallTiming(timing);
- }
- public void PullTest()
- {
- var cont = true;
- SubscriberSettings settings = new SubscriberSettings()
- {
- PullSettings = GetPullSetting()
- };
- SubscriberClient subscriberClient = SubscriberClient.Create(settings: settings);
- var subscriberName = new SubscriptionName("project-name", "subscription-name");
- while (cont)
- {
- try
- {
- PullResponse response = subscriberClient.Pull(subscriberName, returnImmediately: false, maxMessages: 1);
- System.Diagnostics.Trace.WriteLine(">>>>>> " + DateTime.Now.ToString());
- System.Diagnostics.Trace.WriteLine(">>>>>> " + "Job Recieved" + response.ReceivedMessages.ToList().FirstOrDefault());
- subscriberClient.Acknowledge(subscriberName, new List<string>() { response.ReceivedMessages.ToList().FirstOrDefault().AckId });
- }
- catch (Exception ex)
- {
- System.Diagnostics.Trace.WriteLine(">>>>>> " + DateTime.Now.ToString());
- System.Diagnostics.Trace.WriteLine(">>>>>> " + ex.Message);
- }
- }
- }
- public CallSettings GetPullSetting()
- {
- CallTiming timing = CallTiming.FromRetry(new RetrySettings(
- retryBackoff: new BackoffSettings(new TimeSpan(0, 0, 0, 0, 50), new TimeSpan(0, 0, 5), 1),
- timeoutBackoff: new BackoffSettings(new TimeSpan(0, 0, 0, 18, 0), new TimeSpan(0, 0, 20), 1),
- totalExpiration: Google.Api.Gax.Expiration.FromTimeout(TimeSpan.FromMilliseconds(600000))));
- return CallSettings.FromCallTiming(timing);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement