public int PullMessagesSync(string projectId, string subscriptionId, bool acknowledge)
    {
        SubscriptionName           subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
        SubscriberServiceApiClient subscriberClient = SubscriberServiceApiClient.Create();
        int messageCount = 0;

        try
        {
            // Pull messages from server,
            // allowing an immediate response if there are no messages.
            PullResponse response = subscriberClient.Pull(subscriptionName, returnImmediately: false, maxMessages: 20);
            // Print out each received message.
            foreach (ReceivedMessage msg in response.ReceivedMessages)
            {
                string text = System.Text.Encoding.UTF8.GetString(msg.Message.Data.ToArray());
                Console.WriteLine($"Message {msg.Message.MessageId}: {text}");
                Interlocked.Increment(ref messageCount);
            }
            // If acknowledgement required, send to server.
            if (acknowledge && messageCount > 0)
            {
                subscriberClient.Acknowledge(subscriptionName, response.ReceivedMessages.Select(msg => msg.AckId));
            }
        }
        catch (RpcException ex) when(ex.Status.StatusCode == StatusCode.Unavailable)
        {
            // UNAVAILABLE due to too many concurrent pull requests pending for the given subscription.
        }
        return(messageCount);
    }
Beispiel #2
0
    public void DeleteSubscription(string projectId, string subscriptionId)
    {
        SubscriberServiceApiClient subscriber       = SubscriberServiceApiClient.Create();
        SubscriptionName           subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

        subscriber.DeleteSubscription(subscriptionName);
    }
        public static Task Subscribe(string subscriptionId, IServiceScopeFactory scopeFactory)
        {
            var subscriptionName = SubscriptionName.FromProjectSubscription("kwetter-308618", subscriptionId);
            var subscription     = SubscriberClient.CreateAsync(subscriptionName).Result;


            return(subscription.StartAsync((message, _) =>
            {
                var mediator = scopeFactory.CreateScope().ServiceProvider.GetRequiredService <IMediator>();
                var json = Encoding.UTF8.GetString(message.Data.ToArray());

                switch (subscriptionId)
                {
                case "profileservice--user-created":
                    mediator.Send(JsonConvert.DeserializeObject <UserCreatedEvent>(json), _);
                    break;

                case "profileservice--user-deleted":
                    mediator.Send(JsonConvert.DeserializeObject <UserDeletedEvent>(json), _);
                    break;
                }

                return Task.FromResult(SubscriberClient.Reply.Ack);
            }));
        }
Beispiel #4
0
    public static async Task DeleteSubscription(string subscriptionId)
    {
        var subscriber = await SubscriberServiceApiClient.CreateAsync();

        var subscriptionName = SubscriptionName.FromProjectSubscription(ProjectId, subscriptionId);
        await subscriber.DeleteSubscriptionAsync(subscriptionName);
    }
Beispiel #5
0
        public async Task PurgeQueueAsync()
        {
            var topic = new TopicName(_projectId, _inputQueueName);

            try
            {
                var service = await GetPublisherServiceApiClientAsync();

                await service.DeleteTopicAsync(topic);

                Log.Info("Purged topic {topic} by deleting it", topic.ToString());
            }
            catch (RpcException ex) when(ex.StatusCode == StatusCode.NotFound)
            {
                Log.Warn("Tried purging topic {topic} by deleting it, but it could not be found", topic.ToString());
            }

            _subscriptionName = SubscriptionName.FromProjectSubscription(_projectId, _inputQueueName);
            try
            {
                _subscriberClient = await GetSubscriberServiceApiClientAsync();

                await _subscriberClient.DeleteSubscriptionAsync(_subscriptionName);

                Log.Info("Purged subscription {subscriptionname} by deleting it", _subscriptionName.ToString());
            }
            catch (RpcException ex) when(ex.StatusCode == StatusCode.NotFound)
            {
                Log.Info("Tried purging subscription {subscriptionname} by deleting it, but it could not be found", _subscriptionName.ToString());
            }
        }
Beispiel #6
0
    public Subscription GetSubscription(string subscriptionId)
    {
        SubscriberServiceApiClient subscriber       = SubscriberServiceApiClient.Create();
        SubscriptionName           subscriptionName = SubscriptionName.FromProjectSubscription(ProjectId, subscriptionId);

        return(subscriber.GetSubscription(subscriptionName));
    }
Beispiel #7
0
    public async Task <int> PullMessagesAsyncWithDeliveryAttempts(string projectId, string subscriptionId, bool acknowledge)
    {
        // This is an existing subscription with a dead letter policy.
        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

        SubscriberClient subscriber = await SubscriberClient.CreateAsync(subscriptionName);

        int  deliveryAttempt = 0;
        Task startTask       = subscriber.StartAsync((PubsubMessage message, CancellationToken cancel) =>
        {
            string text = Encoding.UTF8.GetString(message.Data.ToArray());
            System.Console.WriteLine($"Delivery Attempt: {message.GetDeliveryAttempt()}");
            if (message.GetDeliveryAttempt() != null)
            {
                deliveryAttempt = message.GetDeliveryAttempt().Value;
            }
            return(Task.FromResult(acknowledge ? SubscriberClient.Reply.Ack : SubscriberClient.Reply.Nack));
        });
        // Run for 7 seconds.
        await Task.Delay(7000);

        await subscriber.StopAsync(CancellationToken.None);

        // Lets make sure that the start task finished successfully after the call to stop.
        await startTask;

        return(deliveryAttempt);
    }
Beispiel #8
0
    public async Task <int> PullMessagesAsync(string projectId, string subscriptionId, bool acknowledge)
    {
        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
        SubscriberClient subscriber       = await SubscriberClient.CreateAsync(subscriptionName);

        // SubscriberClient runs your message handle function on multiple
        // threads to maximize throughput.
        int  messageCount = 0;
        Task startTask    = subscriber.StartAsync((PubsubMessage message, CancellationToken cancel) =>
        {
            string text = System.Text.Encoding.UTF8.GetString(message.Data.ToArray());
            Console.WriteLine($"Message {message.MessageId}: {text}");
            Interlocked.Increment(ref messageCount);
            return(Task.FromResult(acknowledge ? SubscriberClient.Reply.Ack : SubscriberClient.Reply.Nack));
        });
        // Run for 5 seconds.
        await Task.Delay(5000);

        await subscriber.StopAsync(CancellationToken.None);

        // Lets make sure that the start task finished successfully after the call to stop.
        await startTask;

        return(messageCount);
    }
Beispiel #9
0
    public Subscription CreateSubscriptionWithDeadLetterPolicy(string projectId, string subscriptionId, string topicId, string deadLetterTopicId)
    {
        SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create();
        // This is the subscription you want to create with a dead letter policy.
        var subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
        // This is an existing topic that you want to attach the subscription with dead letter policy to.
        var topicName = TopicName.FromProjectTopic(projectId, topicId);
        // This is an existing topic that the subscription with dead letter policy forwards dead letter messages to.
        var deadLetterTopic     = TopicName.FromProjectTopic(projectId, deadLetterTopicId).ToString();
        var subscriptionRequest = new Subscription
        {
            SubscriptionName = subscriptionName,
            TopicAsTopicName = topicName,
            DeadLetterPolicy = new DeadLetterPolicy
            {
                DeadLetterTopic = deadLetterTopic,
                // The maximum number of times that the service attempts to deliver a
                // message before forwarding it to the dead letter topic. Must be [5-100].
                MaxDeliveryAttempts = 10
            },
            AckDeadlineSeconds = 30
        };

        var subscription = subscriber.CreateSubscription(subscriptionRequest);

        Console.WriteLine("Created subscription: " + subscription.SubscriptionName.SubscriptionId);
        Console.WriteLine($"It will forward dead letter messages to: {subscription.DeadLetterPolicy.DeadLetterTopic}");
        Console.WriteLine($"After {subscription.DeadLetterPolicy.MaxDeliveryAttempts} delivery attempts.");
        // Remember to attach a subscription to the dead letter topic because
        // messages published to a topic with no subscriptions are lost.
        return(subscription);
    }
Beispiel #10
0
    public Policy SetSubscriptionIamPolicy(string projectId, string subscriptionId, string role, string member)
    {
        PublisherServiceApiClient publisher = PublisherServiceApiClient.Create();
        string roleToBeAddedToPolicy        = $"roles/{role}";

        Policy policy = new Policy
        {
            Bindings =
            {
                new Binding
                {
                    Role    = roleToBeAddedToPolicy,
                    Members ={ member               }
                }
            }
        };
        SetIamPolicyRequest request = new SetIamPolicyRequest
        {
            ResourceAsResourceName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId),
            Policy = policy
        };
        Policy response = publisher.SetIamPolicy(request);

        return(response);
    }
    public Subscription UpdateDeadLetterPolicy(string projectId, string topicId, string subscriptionId, string deadLetterTopicId)
    {
        SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create();
        // This is an existing topic that the subscription with dead letter policy is attached to.
        TopicName topicName = TopicName.FromProjectTopic(projectId, topicId);
        // This is an existing subscription with a dead letter policy.
        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
        // This is an existing dead letter topic that the subscription with dead letter policy forwards
        // dead letter messages to.
        var deadLetterTopic = TopicName.FromProjectTopic(projectId, deadLetterTopicId).ToString();


        // Construct the subscription with the dead letter policy you expect to have after the update.
        // Here, values in the required fields (name, topic) help identify the subscription.
        var subscription = new Subscription
        {
            SubscriptionName = subscriptionName,
            TopicAsTopicName = topicName,
            DeadLetterPolicy = new DeadLetterPolicy
            {
                DeadLetterTopic = deadLetterTopic,
                MaxDeliveryAttempts = 20,
            }
        };

        var request = new UpdateSubscriptionRequest
        {
            Subscription = subscription,
            // Construct a field mask to indicate which field to update in the subscription.
            UpdateMask = new FieldMask { Paths = { "dead_letter_policy" } }
        };
        var updatedSubscription = subscriber.UpdateSubscription(request);
        return updatedSubscription;
    }
Beispiel #12
0
    public Subscription RemoveDeadLetterPolicy(string projectId, string topicId, string subscriptionId)
    {
        SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create();
        // This is an existing topic that the subscription with dead letter policy is attached to.
        TopicName topicName = TopicName.FromProjectTopic(projectId, topicId);
        // This is an existing subscription with dead letter policy.
        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

        var subscription = new Subscription()
        {
            SubscriptionName = subscriptionName,
            TopicAsTopicName = topicName,
            DeadLetterPolicy = null
        };

        var request = new UpdateSubscriptionRequest
        {
            Subscription = subscription,
            UpdateMask   = new FieldMask {
                Paths = { "dead_letter_policy" }
            }
        };
        var updatedSubscription = subscriber.UpdateSubscription(request);

        return(updatedSubscription);
    }
    public async Task <List <PubsubMessage> > PullMessagesWithCustomAttributesAsync(string projectId, string subscriptionId, bool acknowledge)
    {
        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

        SubscriberClient subscriber = await SubscriberClient.CreateAsync(subscriptionName);

        var  messages  = new List <PubsubMessage>();
        Task startTask = subscriber.StartAsync((PubsubMessage message, CancellationToken cancel) =>
        {
            messages.Add(message);
            string text = System.Text.Encoding.UTF8.GetString(message.Data.ToArray());
            Console.WriteLine($"Message {message.MessageId}: {text}");
            if (message.Attributes != null)
            {
                foreach (var attribute in message.Attributes)
                {
                    Console.WriteLine($"{attribute.Key} = {attribute.Value}");
                }
            }
            return(Task.FromResult(acknowledge ? SubscriberClient.Reply.Ack : SubscriberClient.Reply.Nack));
        });
        // Run for 7 seconds.
        await Task.Delay(7000);

        await subscriber.StopAsync(CancellationToken.None);

        // Lets make sure that the start task finished successfully after the call to stop.
        await startTask;

        return(messages);
    }
Beispiel #14
0
    public async Task <int> PullMessagesWithFlowControlAsync(string projectId, string subscriptionId, bool acknowledge)
    {
        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
        int messageCount            = 0;
        SubscriberClient subscriber = await SubscriberClient.CreateAsync(subscriptionName,
                                                                         settings : new SubscriberClient.Settings()
        {
            AckExtensionWindow  = TimeSpan.FromSeconds(4),
            AckDeadline         = TimeSpan.FromSeconds(10),
            FlowControlSettings = new FlowControlSettings(maxOutstandingElementCount: 100, maxOutstandingByteCount: 10240)
        });

        // SubscriberClient runs your message handle function on multiple
        // threads to maximize throughput.
        Task startTask = subscriber.StartAsync((PubsubMessage message, CancellationToken cancel) =>
        {
            string text = System.Text.Encoding.UTF8.GetString(message.Data.ToArray());
            Console.WriteLine($"Message {message.MessageId}: {text}");
            Interlocked.Increment(ref messageCount);
            return(Task.FromResult(acknowledge ? SubscriberClient.Reply.Ack : SubscriberClient.Reply.Nack));
        });
        // Run for 5 seconds.
        await Task.Delay(5000);

        await subscriber.StopAsync(CancellationToken.None);

        // Lets make sure that the start task finished successfully after the call to stop.
        await startTask;

        return(messageCount);
    }
Beispiel #15
0
    public Subscription CreateSubscriptionWithOrdering(string projectId, string subscriptionId, string topicId)
    {
        SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create();
        var topicName        = TopicName.FromProjectTopic(projectId, topicId);
        var subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

        var subscriptionRequest = new Subscription
        {
            SubscriptionName      = subscriptionName,
            TopicAsTopicName      = topicName,
            EnableMessageOrdering = true
        };

        Subscription subscription = null;

        try
        {
            subscription = subscriber.CreateSubscription(subscriptionRequest);
        }
        catch (RpcException e) when(e.Status.StatusCode == StatusCode.AlreadyExists)
        {
            // Already exists.  That's fine.
        }
        return(subscription);
    }
        public void Delete(string id)
        {
            var subscriber       = SubscriberServiceApiClient.Create();
            var subscriptionName = SubscriptionName.FromProjectSubscription(ProjectId, id);

            subscriber.DeleteSubscription(subscriptionName);
        }
        public IActionResult Get(string id)
        {
            var subscriber       = SubscriberServiceApiClient.Create();
            var subscriptionName = SubscriptionName.FromProjectSubscription(ProjectId, id);
            var subscription     = subscriber.GetSubscription(subscriptionName);

            return(Ok(subscription));
        }
    public Policy GetSubscriptionIamPolicy(string projectId, string subscriptionId)
    {
        PublisherServiceApiClient publisher        = PublisherServiceApiClient.Create();
        SubscriptionName          subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
        Policy policy = publisher.GetIamPolicy(subscriptionName);

        return(policy);
    }
        public void Post([FromBody] CreateTopicRequest request)
        {
            var subscriber = SubscriberServiceApiClient.Create();
            var topicName  = TopicName.FromProjectTopic(ProjectId, request.TopicId);

            var subscriptionName = SubscriptionName.FromProjectSubscription(ProjectId, request.SubscriptionId);

            subscriber.CreateSubscription(subscriptionName, topicName, pushConfig: null, ackDeadlineSeconds: 60);
        }
Beispiel #20
0
        public void SubscriberClientSupport()
        {
            // Sample: SubscriberClient
            SubscriptionName subscription = SubscriptionName.FromProjectSubscription("projectId", "subscriptionId");

            SubscriberClient.ClientCreationSettings clientCreationSettings = new SubscriberClient.ClientCreationSettings()
                                                                             .WithEmulatorDetection(EmulatorDetection.EmulatorOrProduction);
            SubscriberClient client = SubscriberClient.Create(subscription, clientCreationSettings);
            // End sample
        }
    public void UpdatePushConfiguration(string projectId, string subscriptionId, string pushEndpoint)
    {
        SubscriberServiceApiClient subscriber       = SubscriberServiceApiClient.Create();
        SubscriptionName           subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

        PushConfig pushConfig = new PushConfig {
            PushEndpoint = pushEndpoint
        };

        subscriber.ModifyPushConfig(subscriptionName, pushConfig);
    }
    public TestIamPermissionsResponse TestSubscriptionIamPermissionsResponse(string projectId, string subscriptionId)
    {
        TestIamPermissionsRequest request = new TestIamPermissionsRequest
        {
            ResourceAsResourceName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId),
            Permissions            = { "pubsub.subscriptions.get", "pubsub.subscriptions.update" }
        };
        PublisherServiceApiClient  publisher = PublisherServiceApiClient.Create();
        TestIamPermissionsResponse response  = publisher.TestIamPermissions(request);

        return(response);
    }
        public static Task Subscribe(string subscriptionId)
        {
            var subscriptionName = SubscriptionName.FromProjectSubscription("kwetter-308618", subscriptionId);
            var subscription     = SubscriberClient.CreateAsync(subscriptionName).Result;

            return(subscription.StartAsync((message, _) =>
            {
                var json = Encoding.UTF8.GetString(message.Data.ToArray());
                Console.WriteLine($"Message {message.MessageId}: {json}");
                return Task.FromResult(SubscriberClient.Reply.Ack);
            }));
        }
    public void DetachSubscription(string projectId, string subscriptionId)
    {
        PublisherServiceApiClient publisher = PublisherServiceApiClient.Create();

        DetachSubscriptionRequest detachSubscriptionRequest = new DetachSubscriptionRequest
        {
            SubscriptionAsSubscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId),
        };

        publisher.DetachSubscription(detachSubscriptionRequest);

        Console.WriteLine($"Subscription {subscriptionId} is detached.");
    }
    public async Task <int> PullAvroMessagesAsync(string projectId, string subscriptionId, bool acknowledge)
    {
        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
        int messageCount            = 0;
        SubscriberClient subscriber = await SubscriberClient.CreateAsync(subscriptionName,
                                                                         settings : new SubscriberClient.Settings()
        {
            AckExtensionWindow  = TimeSpan.FromSeconds(4),
            AckDeadline         = TimeSpan.FromSeconds(10),
            FlowControlSettings = new FlowControlSettings(maxOutstandingElementCount: 100, maxOutstandingByteCount: 10240)
        });

        // SubscriberClient runs your message handle function on multiple
        // threads to maximize throughput.
        Task startTask = subscriber.StartAsync((PubsubMessage message, CancellationToken cancel) =>
        {
            string encoding           = message.Attributes["googclient_schemaencoding"];
            AvroUtilities.State state = new AvroUtilities.State();
            switch (encoding)
            {
            case "BINARY":
                using (var ms = new MemoryStream(message.Data.ToByteArray()))
                {
                    var decoder = new BinaryDecoder(ms);
                    var reader  = new SpecificDefaultReader(state.Schema, state.Schema);
                    reader.Read <AvroUtilities.State>(state, decoder);
                }
                break;

            case "JSON":
                state = JsonConvert.DeserializeObject <AvroUtilities.State>(message.Data.ToStringUtf8());
                break;

            default:
                Console.WriteLine($"Encoding not provided in message.");
                break;
            }
            Console.WriteLine($"Message {message.MessageId}: {state}");
            Interlocked.Increment(ref messageCount);
            return(Task.FromResult(acknowledge ? SubscriberClient.Reply.Ack : SubscriberClient.Reply.Nack));
        });
        // Run for 5 seconds.
        await Task.Delay(5000);

        await subscriber.StopAsync(CancellationToken.None);

        // Lets make sure that the start task finished successfully after the call to stop.
        await startTask;

        return(messageCount);
    }
Beispiel #26
0
        public void Emulator()
        {
            string projectId      = "projectId";
            string subscriptionId = "subscriptionId";

            // Sample: Emulator
            SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

            SubscriberClient.ClientCreationSettings clientSettings = new SubscriberClient.ClientCreationSettings()
                                                                     .WithEmulatorDetection(EmulatorDetection.EmulatorOrProduction);
            SubscriberClient subscriber = SubscriberClient.Create(subscriptionName, clientSettings);
            // Use subscriber.StartAsync etc as normal
            // End sample
        }
Beispiel #27
0
    public void TestListSubscriptionsInTopic()
    {
        string randomName     = _pubsubFixture.RandomName();
        string topicId        = $"testTopicForListSubscriptionsInTopic{randomName}";
        string subscriptionId = $"testSubscriptionForListSubscriptionsInTopic{randomName}";

        _pubsubFixture.CreateTopic(topicId);
        _pubsubFixture.CreateSubscription(topicId, subscriptionId);

        var subscriptions = _listSubscriptionsInTopicSample.ListSubscriptionsInTopic(_pubsubFixture.ProjectId, topicId).ToList();

        SubscriptionName subscriptionName = SubscriptionName.FromProjectSubscription(_pubsubFixture.ProjectId, subscriptionId);

        Assert.Contains(subscriptions, s => s == subscriptionName.ToString());
    }
        public void DetachSubscriptionRequestObject()
        {
            moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict);
            DetachSubscriptionRequest             request        = new DetachSubscriptionRequest
            {
                SubscriptionAsSubscriptionName = SubscriptionName.FromProjectSubscription("[PROJECT]", "[SUBSCRIPTION]"),
            };
            DetachSubscriptionResponse expectedResponse = new DetachSubscriptionResponse {
            };

            mockGrpcClient.Setup(x => x.DetachSubscription(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            PublisherServiceApiClient  client   = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null);
            DetachSubscriptionResponse response = client.DetachSubscription(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #29
0
    public Subscription CreatePushSubscription(string projectId, string topicId, string subscriptionId, string pushEndpoint)
    {
        SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create();
        TopicName        topicName            = TopicName.FromProjectTopic(projectId, topicId);
        SubscriptionName subscriptionName     = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);

        PushConfig pushConfig = new PushConfig {
            PushEndpoint = pushEndpoint
        };

        // The approximate amount of time in seconds (on a best-effort basis) Pub/Sub waits for the
        // subscriber to acknowledge receipt before resending the message.
        var ackDeadlineSeconds = 60;
        var subscription       = subscriber.CreateSubscription(subscriptionName, topicName, pushConfig, ackDeadlineSeconds);

        return(subscription);
    }
Beispiel #30
0
        public void PullMessages(string subscriptionId, Action <string> action)
        {
            var projectId        = "imposing-elixir-249711";
            var subscriptionName = SubscriptionName.FromProjectSubscription(projectId, subscriptionId);
            SubscriberServiceApiClient subscriber = SubscriberServiceApiClient.Create();
            var response = subscriber.Pull(subscriptionName, returnImmediately: true, maxMessages: 10);

            foreach (ReceivedMessage received in response.ReceivedMessages)
            {
                PubsubMessage msg = received.Message;
                action.Invoke(msg.Data.ToStringUtf8());
            }
            if (response.ReceivedMessages?.Count > 0)
            {
                subscriber.Acknowledge(subscriptionName, response.ReceivedMessages.Select(m => m.AckId));
            }
        }