Multi consumer and single producer which intern is a consumer

时间:2016-04-15 11:08:32

标签: java algorithm logic

I have a scenario to fetch a news feed. The first time I request for information it gives me a set of feeds with each feed having a feedId, the feedIds are not in a sequential order(The feedIds are jumbled withIn the set of feeds). The news feed count is limited to a fixed value. If I supply the last fetched feedId from the current set of feeds to the next request it returns me the next set of feeds and this continues. My question here is how to run this kind of problem in a multi-threaded environment?

I have tried getting the first feedID and adding a batchSize of 2000(some random size) between multiple news feed fetcher and I could see two scenarios:

  1. There are missing news feed between the last feedId of the last batch and the consequtive batch.
  2. Duplicate news feeds with the same Ids.

Can anyone help me with a thought?

0 个答案:

没有答案
相关问题