return to async beans, jms is too much overhead atm

This commit is contained in:
Athou
2013-04-25 17:26:07 +02:00
parent 84f9b4e10e
commit 2af55553a2
4 changed files with 55 additions and 153 deletions

View File

@@ -1,81 +0,0 @@
package com.commafeed.backend.feeds;
import java.io.Serializable;
import java.util.Collection;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.services.FeedUpdateService;
@MessageDriven(name = "FeedRefreshUpdater", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/refreshQueue") })
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class FeedRefreshUpdater implements MessageListener {
private static Logger log = LoggerFactory
.getLogger(FeedRefreshUpdater.class);
@Inject
FeedDAO feedDAO;
@Inject
FeedUpdateService feedUpdateService;
@Override
public void onMessage(Message message) {
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
try {
FeedRefreshTask task = (FeedRefreshTask) objectMessage
.getObject();
if (task.getEntries() != null) {
feedUpdateService.updateEntries(task.getFeed(),
task.getEntries());
} else {
feedDAO.update(task.getFeed());
}
} catch (JMSException e) {
log.error(e.getMessage(), e);
}
}
}
public static class FeedRefreshTask implements Serializable {
private static final long serialVersionUID = 1L;
private Feed feed;
private Collection<FeedEntry> entries;
public FeedRefreshTask(Feed feed, Collection<FeedEntry> entries) {
this.feed = feed;
this.entries = entries;
}
public Feed getFeed() {
return feed;
}
public Collection<FeedEntry> getEntries() {
return entries;
}
}
}