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 PersistedMessageBO 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 return getMessageQueueDao().save(routeQueue);
51 }
52 return routeQueue;
53 }
54
55 public List<PersistedMessageBO> findAll() {
56 return this.getMessageQueueDao().findAll();
57 }
58
59 public List<PersistedMessageBO> findAll(int maxRows) {
60 return this.getMessageQueueDao().findAll(maxRows);
61 }
62
63 public PersistedMessageBO findByRouteQueueId(Long routeQueueId) {
64 return getMessageQueueDao().findByRouteQueueId(routeQueueId);
65 }
66
67 public PersistedMessagePayload findByPersistedMessageByRouteQueueId(Long routeQueueId) {
68 return messageQueueDao.findByPersistedMessageByRouteQueueId(routeQueueId);
69 }
70
71 public List<PersistedMessageBO> getNextDocuments(Integer maxDocuments) {
72 return this.getMessageQueueDao().getNextDocuments(maxDocuments);
73 }
74
75 public MessageQueueDAO getMessageQueueDao() {
76 return this.messageQueueDao;
77 }
78
79 public void setMessageQueueDao(MessageQueueDAO queueDAO) {
80 this.messageQueueDao = queueDAO;
81 }
82
83 public List<PersistedMessageBO> findByServiceName(QName serviceName, String methodName) {
84 return getMessageQueueDao().findByServiceName(serviceName, methodName);
85 }
86
87 public List<PersistedMessageBO> findByValues(Map<String, String> criteriaValues, int maxRows) {
88 return getMessageQueueDao().findByValues(criteriaValues, maxRows);
89 }
90
91 public Integer getMaxRetryAttempts() {
92 return new Integer(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.ROUTE_QUEUE_MAX_RETRY_ATTEMPTS_KEY));
93 }
94
95 }