com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest Java Examples

The following examples show how to use com.amazonaws.services.sns.model.ListSubscriptionsByTopicRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SnsMessageBroker.java    From xyz-hub with Apache License 2.0 5 votes vote down vote up
private void loadSubscriptions(String nextToken, Handler<AsyncResult<List<Subscription>>> callback) {
  ListSubscriptionsByTopicRequest req = new ListSubscriptionsByTopicRequest()
      .withTopicArn(TOPIC_ARN);
  if (nextToken != null) {
    req.setNextToken(nextToken);
  }
  SNS_CLIENT.listSubscriptionsByTopicAsync(req,
      new AsyncHandler<ListSubscriptionsByTopicRequest, ListSubscriptionsByTopicResult>() {
        @Override
        public void onError(Exception e) {
          callback.handle(Future.failedFuture(e));
        }

        @Override
        public void onSuccess(ListSubscriptionsByTopicRequest request, ListSubscriptionsByTopicResult result) {
          List<Subscription> subscriptions = result.getSubscriptions()
              .stream()
              .filter(subscription -> SNS_HTTP_PROTOCOL.equals(subscription.getProtocol())
                  && subscription.getEndpoint().contains(AdminApi.ADMIN_MESSAGES_ENDPOINT))
              .collect(Collectors.toCollection(LinkedList::new));
          if (result.getNextToken() != null) {
            loadSubscriptions(result.getNextToken(), subscriptionsResult -> {
              if (subscriptionsResult.succeeded()) {
                subscriptions.addAll(subscriptionsResult.result());
                callback.handle(Future.succeededFuture(subscriptions));
              } else {
                callback.handle(subscriptionsResult);
              }
            });
          }
          else {
            callback.handle(Future.succeededFuture(subscriptions));
          }
        }
      });
}
 
Example #2
Source File: TopicImpl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public SubscriptionCollection getSubscriptions(
        ListSubscriptionsByTopicRequest request) {

    ResourceCollectionImpl result = resource.getCollection("Subscriptions",
            request);

    if (result == null) return null;
    return new SubscriptionCollectionImpl(result);
}
 
Example #3
Source File: Topic.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves the Subscriptions collection referenced by this resource.
 */
SubscriptionCollection getSubscriptions(ListSubscriptionsByTopicRequest
        request);