only allow one thread to update entries for a feed, avoids duplicates if two feeds containing the same entry are updating at the same time

This commit is contained in:
Athou
2013-04-26 18:53:48 +02:00
parent aa3baf5007
commit 56ba907ec5
3 changed files with 79 additions and 56 deletions

View File

@@ -0,0 +1,33 @@
package com.commafeed.backend.feeds;
import java.util.Collection;
import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
import javax.inject.Inject;
import org.apache.commons.collections.CollectionUtils;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.services.FeedUpdateService;
@Stateless
public class FeedRefreshUpdater {
@Inject
FeedUpdateService feedUpdateService;
@Inject
FeedDAO feedDAO;
@Asynchronous
public void updateEntries(Feed feed, Collection<FeedEntry> entries) {
if (CollectionUtils.isNotEmpty(entries)) {
feedUpdateService.updateEntries(feed, entries);
}
feedDAO.update(feed);
}
}