1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging.service.impl;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.config.property.ConfigContext;
20 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
21 import org.kuali.rice.ksb.messaging.PersistedMessagePayload;
22 import org.kuali.rice.ksb.messaging.dao.MessageQueueDAO;
23 import org.kuali.rice.ksb.messaging.service.MessageQueueService;
24 import org.kuali.rice.ksb.util.KSBConstants;
25
26 import javax.xml.namespace.QName;
27 import java.util.List;
28 import java.util.Map;
29
30 public class MessageQueueServiceImpl implements MessageQueueService {
31
32
33 private static final Logger LOG = Logger.getLogger(MessageQueueServiceImpl.class);
34 private MessageQueueDAO messageQueueDao;
35
36 public void delete(PersistedMessageBO routeQueue) {
37 if (Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGE_PERSISTENCE))) {
38 if (LOG.isDebugEnabled()) {
39 LOG.debug("Message Persistence is on. Deleting stored message" + routeQueue);
40 }
41 this.getMessageQueueDao().remove(routeQueue);
42 }
43 }
44
45 public void save(PersistedMessageBO routeQueue) {
46 if (Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGE_PERSISTENCE))) {
47 if (LOG.isDebugEnabled()) {
48 LOG.debug("Persisting Message " + routeQueue);
49 }
50 this.getMessageQueueDao().save(routeQueue);
51 }
52 }
53
54 public List<PersistedMessageBO> findAll() {
55 return this.getMessageQueueDao().findAll();
56 }
57
58 public List<PersistedMessageBO> findAll(int maxRows) {
59 return this.getMessageQueueDao().findAll(maxRows);
60 }
61
62 public PersistedMessageBO findByRouteQueueId(Long routeQueueId) {
63 return getMessageQueueDao().findByRouteQueueId(routeQueueId);
64 }
65
66 public PersistedMessagePayload findByPersistedMessageByRouteQueueId(Long routeQueueId) {
67 return messageQueueDao.findByPersistedMessageByRouteQueueId(routeQueueId);
68 }
69
70 public List<PersistedMessageBO> getNextDocuments(Integer maxDocuments) {
71 return this.getMessageQueueDao().getNextDocuments(maxDocuments);
72 }
73
74 public MessageQueueDAO getMessageQueueDao() {
75 return this.messageQueueDao;
76 }
77
78 public void setMessageQueueDao(MessageQueueDAO queueDAO) {
79 this.messageQueueDao = queueDAO;
80 }
81
82 public List<PersistedMessageBO> findByServiceName(QName serviceName, String methodName) {
83 return getMessageQueueDao().findByServiceName(serviceName, methodName);
84 }
85
86 public List<PersistedMessageBO> findByValues(Map<String, String> criteriaValues, int maxRows) {
87 return getMessageQueueDao().findByValues(criteriaValues, maxRows);
88 }
89
90 public Integer getMaxRetryAttempts() {
91 return new Integer(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.ROUTE_QUEUE_MAX_RETRY_ATTEMPTS_KEY));
92 }
93
94 }