Example usage for com.amazonaws.services.sns.model ListSubscriptionsByTopicRequest ListSubscriptionsByTopicRequest

List of usage examples for com.amazonaws.services.sns.model ListSubscriptionsByTopicRequest ListSubscriptionsByTopicRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.sns.model ListSubscriptionsByTopicRequest ListSubscriptionsByTopicRequest.

Prototype

public ListSubscriptionsByTopicRequest(String topicArn) 

Source Link

Document

Constructs a new ListSubscriptionsByTopicRequest object.

Usage

From source file:awslabs.lab31.StudentCode.java

License:Open Source License

/**
 * Delete all subscriptions to the specified SNS topic. Hint: Call getSubscriptions() on the client object to get
 * all of the subscriptions and loop through them calling the client object's unsubscribe() method with details of
 * each subscription./*from   ww  w .  j  a v  a2s  .  c o  m*/
 * 
 * @param snsClient The SNS client object.
 * @param topicArn The SNS topic to remove the subscriptions from.
 */
@Override
public void deleteSubscriptions(AmazonSNSClient snsClient, String topicArn) {
    ListSubscriptionsByTopicRequest request = new ListSubscriptionsByTopicRequest(topicArn);
    ListSubscriptionsByTopicResult result = snsClient.listSubscriptionsByTopic(request);

    for (Subscription s : result.getSubscriptions()) {
        UnsubscribeRequest unsubscribeRequest = new UnsubscribeRequest(s.getSubscriptionArn());
        snsClient.unsubscribe(unsubscribeRequest);
    }
}

From source file:com.amazon.aws.demo.anonymous.sns.SimpleNotification.java

License:Open Source License

public static List<String> getSubscriptionNamesByTopic(String topicARN) {
    List subscriptions;//  w  w  w . j av  a  2  s  .  co m
    if (topicARN != null) {
        ListSubscriptionsByTopicRequest req = new ListSubscriptionsByTopicRequest(topicARN);
        subscriptions = getInstance().listSubscriptionsByTopic(req).getSubscriptions();
    } else {
        subscriptions = getInstance().listSubscriptions().getSubscriptions();
    }
    Iterator sIter = subscriptions.iterator();
    List<String> subscriptionNames = new ArrayList<String>(subscriptions.size());
    while (sIter.hasNext()) {
        subscriptionNames.add(((Subscription) sIter.next()).getEndpoint());
    }
    return subscriptionNames;
}

From source file:com.pocketdealhunter.HotDealsMessagesUtil.java

License:Open Source License

public List<Subscription> listSubscribers() {
    try {//from  w  ww.  jav  a  2 s.  com
        ListSubscriptionsByTopicRequest ls = new ListSubscriptionsByTopicRequest(this.topicARN);
        ListSubscriptionsByTopicResult response = this.snsClient.listSubscriptionsByTopic(ls);
        return response.getSubscriptions();
    } catch (Exception exception) {
        System.out.println("Exception  = " + exception);
        return Collections.emptyList();
    }
}