Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient.ListSubscriptionsByTopicAsync C# (CSharp) Метод

ListSubscriptionsByTopicAsync() публичный Метод

Returns a list of the subscriptions to a specific topic. Each call returns a limited list of subscriptions, up to 100. If there are more subscriptions, a NextToken is also returned. Use the NextToken parameter in a new ListSubscriptionsByTopic call to get further results.
/// Indicates that the user has been denied access to the requested resource. /// /// Indicates an internal service error. /// /// Indicates that a request parameter does not comply with the associated constraints. /// /// Indicates that the requested resource does not exist. ///
public ListSubscriptionsByTopicAsync ( string topicArn, string nextToken, System cancellationToken = default(CancellationToken) ) : Task
topicArn string The ARN of the topic for which you wish to find subscriptions.
nextToken string Token returned by the previous ListSubscriptionsByTopic request.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
Результат Task
        public Task<ListSubscriptionsByTopicResponse> ListSubscriptionsByTopicAsync(string topicArn, string nextToken, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new ListSubscriptionsByTopicRequest();
            request.TopicArn = topicArn;
            request.NextToken = nextToken;
            return ListSubscriptionsByTopicAsync(request, cancellationToken);
        }

Same methods

AmazonSimpleNotificationServiceClient::ListSubscriptionsByTopicAsync ( ListSubscriptionsByTopicRequest request, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::ListSubscriptionsByTopicAsync ( string topicArn, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::ListSubscriptionsByTopicAsync ( ListSubscriptionsByTopicRequest request, ListSubscriptionsByTopicResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonSimpleNotificationServiceClient::ListSubscriptionsByTopicAsync ( string topicArn, ListSubscriptionsByTopicResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonSimpleNotificationServiceClient::ListSubscriptionsByTopicAsync ( string topicArn, string nextToken, ListSubscriptionsByTopicResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

Пример #1
0
        public void ReloadExistingSubscriptions()
        {
            var subscriptions = new List <SubscriptionInfo>();

            using (var client = new AmazonSimpleNotificationServiceClient(this.AwsCredentials, this.AwsRegion)) {
                var request = new ListTopicsRequest();
                ListTopicsResponse        response;
                Task <ListTopicsResponse> ltt;

                do
                {
                    ltt = client.ListTopicsAsync(request);
                    ltt.Wait();
                    response = ltt.Result;

                    foreach (var topic in response.Topics)
                    {
                        var lsRequest = new ListSubscriptionsByTopicRequest()
                        {
                            TopicArn = topic.TopicArn
                        };
                        ListSubscriptionsByTopicResponse        lsResponse;
                        Task <ListSubscriptionsByTopicResponse> lst;

                        do
                        {
                            lst = client.ListSubscriptionsByTopicAsync(lsRequest);
                            lst.Wait();
                            lsResponse = lst.Result;

                            //íterate all subscriptions which are bound to our SubscriptionCallbackUrl...
                            foreach (var subscription in lsResponse.Subscriptions.Where(s => string.Equals(s.Endpoint, this.SubscriptionCallbackUrl, StringComparison.InvariantCultureIgnoreCase)))
                            {
                                //skip pending subscriptions...
                                if (!subscription.SubscriptionArn.Equals(AwsMagicArnForPendingSubscription))
                                {
                                    subscriptions.Add(new SubscriptionInfo(this, subscription.TopicArn, subscription.SubscriptionArn, false));
                                }
                            }

                            lsRequest.NextToken = lsResponse.NextToken;
                        } while (!string.IsNullOrEmpty(lsResponse.NextToken));
                    }

                    request.NextToken = response.NextToken;
                } while (!string.IsNullOrEmpty(response.NextToken));

                lock (_ConfirmedSubscriptions) {
                    _ConfirmedSubscriptions = subscriptions;
                }

                lock (_LocalPendingSubscriptions) {
                    foreach (var lps in _LocalPendingSubscriptions.ToArray())
                    {
                        if (subscriptions.Where(s => (s.TopicArn ?? "") == (lps.TopicArn ?? "")).Any())
                        {
                            _LocalPendingSubscriptions.Remove(lps);
                        }
                    }
                }
            }
        }
AmazonSimpleNotificationServiceClient