Retrofit: How to make queue request in Retrofit so that retrofit calls 5 request at a time and after that picks another 5 call from queue

Created on 8 Jan 2018  路  1Comment  路  Source: square/retrofit

I want that if i loop my request it should put it into queue and At a time is should process for 5 request at a time . So How can i implement it. As below I am doing: -

Please help me regarding this

for (int i=0; i<100;i++){

Call call=ApiClient.INSTANCE.getClient().getStoryListById(getStoriesByIDRequest);
// Call call = service.getMovieResponse(sortKey, ApiKey.API_KEY);
call.enqueue(new Callback() {
@Override
public void onResponse(Callcall, Response response) {
if(response.body()!=null)
{
AppDatabase.getDatabase(getApplicationContext()).storyDao().
insertStoryContentAndImages(response.body().getResult());
}
else
{

                }

            }

            @Override
            public void onFailure(Call<GetStoriesByIDTop>call, Throwable t) {

            }
        });

}

Most helpful comment

You will have to implement such a specific requirement at the application layer or in a custom CallAdapter.

If you need help doing that, please ask a question on StackOverflow with the 'retrofit' tag which is where we have a small community of people which help resolve usage questions like these.

>All comments

You will have to implement such a specific requirement at the application layer or in a custom CallAdapter.

If you need help doing that, please ask a question on StackOverflow with the 'retrofit' tag which is where we have a small community of people which help resolve usage questions like these.

Was this page helpful?
0 / 5 - 0 ratings