简体   繁体   中英

Getting the subscription list under a topic in SNS via AWS SDK for Java

I have working on a project where I have to get the list of all the endpoint subscriptions that happened under the Application in AWS SNS Application.

ListEndpointsByPlatformApplicationRequest request = new ListEndpointsByPlatformApplicationRequest();
request.setPlatformApplicationArn(applicationArn);

ListEndpointsByPlatformApplicationResult result = sns.listEndpointsByPlatformApplication(request);
List<Endpoint> endpoints = result.getEndpoints();
for(Endpoint endpoint : result.getEndpoints()){
    //System.out.println(endpoint.getEndpointArn());
    count++;
}

The count always is 100 and the list that comes is also same I checked it via printing and getting the data out of it.

Where am I doing wrong. I know there is something connected with the token that we get using getNextToken() function but unable to do it.

Please help how to get the total number of endpoint subscription under an Application in SNS via AWS SDK using Java.

Thanks Ankur :)

You need to use the returned token to return the next page of results as detailed

So your next request would be:

String token = tokenFromPreviousRequest();
ListEndpointsByPlatformApplicationRequest request = 
    new ListEndpointsByPlatformApplicationRequest();
request.setPlatformApplicationArn(applicationArn);
request.setNextToken(token);

ListEndpointsByPlatformApplicationResult result = 
    sns.listEndpointsByPlatformApplication(request);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM