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

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

Initiates the asynchronous execution of the ListSubscriptionsByTopic operation.
public ListSubscriptionsByTopicAsync ( ListSubscriptionsByTopicRequest request, System cancellationToken = default(CancellationToken) ) : Task
request Amazon.SimpleNotificationService.Model.ListSubscriptionsByTopicRequest Container for the necessary parameters to execute the ListSubscriptionsByTopic operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
Результат Task
        public Task<ListSubscriptionsByTopicResponse> ListSubscriptionsByTopicAsync(ListSubscriptionsByTopicRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ListSubscriptionsByTopicRequestMarshaller();
            var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.Instance;

            return InvokeAsync<ListSubscriptionsByTopicRequest,ListSubscriptionsByTopicResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }

Same methods

AmazonSimpleNotificationServiceClient::ListSubscriptionsByTopicAsync ( string topicArn, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::ListSubscriptionsByTopicAsync ( string topicArn, string nextToken, 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