예제 #1
0
        static SimpleSubscriber GetSimpleSubscriber(string projectId,
                                                    string subscriptionId)
        {
            // [START pull_messages]
            SubscriptionName subscriptionName = new SubscriptionName(projectId,
                                                                     subscriptionId);
            SubscriberClient subscriberClient = SubscriberClient.Create();
            SimpleSubscriber subscriber       = SimpleSubscriber.Create(
                subscriptionName, new[] { subscriberClient });

            // [END pull_messages]
            return(subscriber);
        }
예제 #2
0
        /// <summary>
        /// Create a subscriber with custom control flow settings.
        /// </summary>
        static SimpleSubscriber GetCustomSubscriber(string projectId,
                                                    string subscriptionId)
        {
            // [START pubsub_subscriber_flow_settings]
            SubscriptionName subscriptionName = new SubscriptionName(projectId,
                                                                     subscriptionId);
            SubscriberClient subscriberClient = SubscriberClient.Create();
            SimpleSubscriber subscriber       = SimpleSubscriber.Create(
                subscriptionName, new[] { subscriberClient },
                new SimpleSubscriber.Settings()
            {
                AckExtensionWindow  = TimeSpan.FromSeconds(4),
                Scheduler           = Google.Api.Gax.SystemScheduler.Instance,
                StreamAckDeadline   = TimeSpan.FromSeconds(10),
                FlowControlSettings = new Google.Api.Gax
                                      .FlowControlSettings(
                    maxOutstandingElementCount: 100,
                    maxOutstandardByteCount: 10240)
            });

            // [END pubsub_subscriber_flow_settings]
            return(subscriber);
        }