Reputation: 5933
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 :)
Upvotes: 1
Views: 1077
Reputation: 21184
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);
Upvotes: 1