1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.ksb.messaging.web; |
18 | |
|
19 | |
import org.apache.commons.collections.comparators.ComparableComparator; |
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.apache.commons.lang.math.NumberUtils; |
22 | |
import org.apache.struts.action.ActionForm; |
23 | |
import org.apache.struts.action.ActionForward; |
24 | |
import org.apache.struts.action.ActionMapping; |
25 | |
import org.apache.struts.action.ActionMessage; |
26 | |
import org.apache.struts.action.ActionMessages; |
27 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
28 | |
import org.kuali.rice.core.util.ConcreteKeyValue; |
29 | |
import org.kuali.rice.core.util.RiceConstants; |
30 | |
import org.kuali.rice.core.util.RiceUtilities; |
31 | |
import org.kuali.rice.ksb.messaging.AsynchronousCall; |
32 | |
import org.kuali.rice.ksb.messaging.MessageFetcher; |
33 | |
import org.kuali.rice.ksb.messaging.MessageServiceInvoker; |
34 | |
import org.kuali.rice.ksb.messaging.PersistedMessageBO; |
35 | |
import org.kuali.rice.ksb.messaging.RemoteResourceServiceLocator; |
36 | |
import org.kuali.rice.ksb.messaging.ServiceInfo; |
37 | |
import org.kuali.rice.ksb.messaging.callforwarding.ForwardedCallHandler; |
38 | |
import org.kuali.rice.ksb.messaging.resourceloader.KSBResourceLoaderFactory; |
39 | |
import org.kuali.rice.ksb.messaging.service.MessageQueueService; |
40 | |
import org.kuali.rice.ksb.service.KSBServiceLocator; |
41 | |
import org.kuali.rice.ksb.util.KSBConstants; |
42 | |
|
43 | |
import javax.servlet.ServletException; |
44 | |
import javax.servlet.http.HttpServletRequest; |
45 | |
import javax.servlet.http.HttpServletResponse; |
46 | |
import javax.xml.namespace.QName; |
47 | |
import java.io.IOException; |
48 | |
import java.sql.Timestamp; |
49 | |
import java.util.ArrayList; |
50 | |
import java.util.Calendar; |
51 | |
import java.util.Collections; |
52 | |
import java.util.Comparator; |
53 | |
import java.util.Date; |
54 | |
import java.util.HashMap; |
55 | |
import java.util.Iterator; |
56 | |
import java.util.List; |
57 | |
import java.util.Map; |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | 0 | public class MessageQueueAction extends KSBAction { |
66 | |
|
67 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(MessageQueueAction.class); |
68 | |
|
69 | |
@Override |
70 | |
public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
71 | |
HttpServletResponse response) throws IOException, ServletException { |
72 | 0 | return mapping.findForward("report"); |
73 | |
} |
74 | |
|
75 | |
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
76 | |
HttpServletResponse response) throws Exception { |
77 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
78 | 0 | save(routeQueueForm); |
79 | |
|
80 | 0 | routeQueueForm.getMessageQueueFromForm().getRouteQueueId(); |
81 | 0 | ActionMessages messages = new ActionMessages(); |
82 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("routequeue.RouteQueueService.saved")); |
83 | 0 | saveMessages(request, messages); |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | 0 | return mapping.findForward("report"); |
96 | |
} |
97 | |
|
98 | |
public ActionForward saveAndResubmit(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
99 | |
HttpServletResponse response) throws Exception { |
100 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
101 | 0 | PersistedMessageBO message = save(routeQueueForm); |
102 | 0 | KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message)); |
103 | |
|
104 | 0 | ActionMessages messages = new ActionMessages(); |
105 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("routequeue.RouteQueueService.queued")); |
106 | 0 | saveMessages(request, messages); |
107 | |
|
108 | 0 | routeQueueForm.setMessageId(null); |
109 | 0 | routeQueueForm.setMessageQueueFromDatabase(null); |
110 | 0 | routeQueueForm.setMessageQueueFromForm(null); |
111 | 0 | routeQueueForm.setShowEdit("yes"); |
112 | 0 | routeQueueForm.setMethodToCall(""); |
113 | 0 | establishRequiredState(request, form); |
114 | 0 | routeQueueForm.setMessageId(message.getRouteQueueId()); |
115 | 0 | routeQueueForm.setMessageQueueFromForm(message); |
116 | 0 | routeQueueForm.setNewQueueDate(routeQueueForm.getExistingQueueDate()); |
117 | 0 | routeQueueForm.getMessageQueueFromForm().setMethodCall(unwrapPayload(message)); |
118 | 0 | return mapping.findForward("report"); |
119 | |
} |
120 | |
|
121 | |
public ActionForward saveAndForward(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
122 | |
HttpServletResponse response) throws Exception { |
123 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
124 | 0 | PersistedMessageBO message = save(routeQueueForm); |
125 | 0 | ForwardedCallHandler adminService = getAdminServiceToForwardTo(message, routeQueueForm); |
126 | 0 | AsynchronousCall methodCall = message.getPayload().getMethodCall(); |
127 | 0 | message.setMethodCall(methodCall); |
128 | 0 | adminService.handleCall(message); |
129 | 0 | KSBServiceLocator.getRouteQueueService().delete(message); |
130 | |
|
131 | 0 | ActionMessages messages = new ActionMessages(); |
132 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("routequeue.RouteQueueService.queued")); |
133 | 0 | saveMessages(request, messages); |
134 | |
|
135 | 0 | routeQueueForm.setMessageId(null); |
136 | 0 | routeQueueForm.setMessageQueueFromDatabase(null); |
137 | 0 | routeQueueForm.setMessageQueueFromForm(null); |
138 | 0 | routeQueueForm.setShowEdit("yes"); |
139 | 0 | routeQueueForm.setMethodToCall(""); |
140 | 0 | establishRequiredState(request, form); |
141 | 0 | routeQueueForm.setMessageId(message.getRouteQueueId()); |
142 | 0 | routeQueueForm.setMessageQueueFromForm(message); |
143 | 0 | routeQueueForm.setNewQueueDate(routeQueueForm.getExistingQueueDate()); |
144 | 0 | routeQueueForm.getMessageQueueFromForm().setMethodCall(unwrapPayload(message)); |
145 | 0 | return mapping.findForward("report"); |
146 | |
} |
147 | |
|
148 | |
private PersistedMessageBO save(MessageQueueForm routeQueueForm) { |
149 | 0 | Long routeQueueId = routeQueueForm.getMessageQueueFromForm().getRouteQueueId(); |
150 | 0 | if ((routeQueueId == null) || (routeQueueId.longValue() <= 0)) { |
151 | 0 | throw new IllegalArgumentException("Invalid routeQueueId passed in. Cannot save"); |
152 | |
} |
153 | |
|
154 | 0 | PersistedMessageBO existingMessage = KSBServiceLocator.getRouteQueueService().findByRouteQueueId(routeQueueId); |
155 | 0 | PersistedMessageBO message = routeQueueForm.getMessageQueueFromForm(); |
156 | |
|
157 | 0 | if (existingMessage == null) { |
158 | 0 | throw new RuntimeException("Could locate the existing message, it may have already been processed."); |
159 | |
} |
160 | |
|
161 | 0 | existingMessage.setQueuePriority(message.getQueuePriority()); |
162 | 0 | existingMessage.setIpNumber(message.getIpNumber()); |
163 | 0 | existingMessage.setLockVerNbr(message.getLockVerNbr()); |
164 | 0 | existingMessage.setServiceNamespace(message.getServiceNamespace()); |
165 | 0 | existingMessage.setMethodName(message.getMethodName()); |
166 | 0 | existingMessage.setQueueStatus(message.getQueueStatus()); |
167 | 0 | existingMessage.setRetryCount(message.getRetryCount()); |
168 | 0 | existingMessage.setServiceName(message.getServiceName()); |
169 | 0 | existingMessage.setValue1(message.getValue1()); |
170 | 0 | existingMessage.setValue2(message.getValue2()); |
171 | 0 | KSBServiceLocator.getRouteQueueService().save(existingMessage); |
172 | 0 | return existingMessage; |
173 | |
} |
174 | |
|
175 | |
private ForwardedCallHandler getAdminServiceToForwardTo(PersistedMessageBO message, MessageQueueForm form) { |
176 | 0 | String ip = form.getIpAddress(); |
177 | 0 | List<ServiceInfo> services = KSBServiceLocator.getServiceRegistry().fetchAll(); |
178 | 0 | for (ServiceInfo service : services) { |
179 | 0 | if (service.getQname().getLocalPart().equals( |
180 | |
QName.valueOf(message.getServiceName()).getLocalPart() + "-forwardHandler") |
181 | |
&& service.getServerIp().equals(ip)) { |
182 | |
|
183 | 0 | RemoteResourceServiceLocator remoteResourceLocator = KSBResourceLoaderFactory.getRemoteResourceLocator(); |
184 | 0 | ForwardedCallHandler handler = (ForwardedCallHandler) remoteResourceLocator.getService(service.getQname(), service.getEndpointUrl()); |
185 | 0 | if (handler != null) { |
186 | 0 | return handler; |
187 | |
} else { |
188 | 0 | LOG.warn("Failed to find forwarded call handler for service: " + service.getQname().toString() + " and endpoint URL: " + service.getEndpointUrl()); |
189 | |
} |
190 | 0 | } |
191 | |
} |
192 | 0 | throw new RuntimeException("Could not locate the BusAdminService for ip " + ip |
193 | |
+ " in order to forward the message."); |
194 | |
} |
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
protected void quickRequeueMessage(PersistedMessageBO message) { |
206 | 0 | message.setQueueStatus(KSBConstants.ROUTE_QUEUE_ROUTING); |
207 | 0 | message.setQueueDate(new Timestamp(Calendar.getInstance().getTimeInMillis())); |
208 | 0 | message.setRetryCount(new Integer(0)); |
209 | 0 | getRouteQueueService().save(message); |
210 | 0 | } |
211 | |
|
212 | |
public ActionForward quickRequeueMessage(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
213 | |
HttpServletResponse response) throws Exception { |
214 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
215 | 0 | if (routeQueueForm.getMessageQueueFromDatabase() == null) { |
216 | 0 | throw new IllegalArgumentException("No messageId passed in with the Request."); |
217 | |
} |
218 | |
|
219 | 0 | PersistedMessageBO message = routeQueueForm.getMessageQueueFromDatabase(); |
220 | 0 | quickRequeueMessage(message); |
221 | 0 | KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message)); |
222 | |
|
223 | 0 | ActionMessages messages = new ActionMessages(); |
224 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("routequeue.RouteQueueService.requeued")); |
225 | 0 | saveMessages(request, messages); |
226 | |
|
227 | 0 | routeQueueForm.setMessageQueueFromDatabase(null); |
228 | 0 | routeQueueForm.setMessageQueueFromForm(null); |
229 | 0 | routeQueueForm.setMessageId(null); |
230 | 0 | routeQueueForm.setMethodToCall(""); |
231 | |
|
232 | |
|
233 | 0 | establishRequiredState(request, form); |
234 | 0 | return mapping.findForward("report"); |
235 | |
} |
236 | |
|
237 | |
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
238 | |
HttpServletResponse response) throws IOException, ServletException { |
239 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
240 | 0 | routeQueueForm.setShowEdit("yes"); |
241 | 0 | routeQueueForm.setMessageQueueFromForm(routeQueueForm.getMessageQueueFromDatabase()); |
242 | 0 | routeQueueForm.setNewQueueDate(routeQueueForm.getExistingQueueDate()); |
243 | 0 | routeQueueForm.getMessageQueueFromForm().setMethodCall(unwrapPayload(routeQueueForm.getMessageQueueFromForm())); |
244 | 0 | return mapping.findForward("basic"); |
245 | |
} |
246 | |
|
247 | |
public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
248 | |
HttpServletResponse response) throws Exception { |
249 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
250 | 0 | routeQueueForm.setShowEdit("no"); |
251 | 0 | routeQueueForm.setMessageQueueFromForm(routeQueueForm.getMessageQueueFromDatabase()); |
252 | 0 | routeQueueForm.setNewQueueDate(routeQueueForm.getExistingQueueDate()); |
253 | 0 | AsynchronousCall messagePayload = unwrapPayload(routeQueueForm.getMessageQueueFromDatabase()); |
254 | 0 | routeQueueForm.getMessageQueueFromForm().setMethodCall(messagePayload); |
255 | 0 | return mapping.findForward("payload"); |
256 | |
} |
257 | |
|
258 | |
public ActionForward reset(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
259 | |
HttpServletResponse response) throws Exception { |
260 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
261 | 0 | if (routeQueueForm.getShowEdit().equals("yes")) { |
262 | 0 | routeQueueForm.setMessageQueueFromForm(routeQueueForm.getMessageQueueFromDatabase()); |
263 | |
} |
264 | 0 | return mapping.findForward("basic"); |
265 | |
} |
266 | |
|
267 | |
public ActionForward clear(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
268 | |
HttpServletResponse response) throws Exception { |
269 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
270 | 0 | routeQueueForm.getMessageQueueFromForm().setQueuePriority(null); |
271 | 0 | routeQueueForm.getMessageQueueFromForm().setQueueStatus(null); |
272 | 0 | routeQueueForm.getMessageQueueFromForm().setQueueDate(null); |
273 | 0 | routeQueueForm.getMessageQueueFromForm().setExpirationDate(null); |
274 | 0 | routeQueueForm.getMessageQueueFromForm().setRetryCount(null); |
275 | 0 | routeQueueForm.getMessageQueueFromForm().setIpNumber(null); |
276 | 0 | routeQueueForm.getMessageQueueFromForm().setServiceName(null); |
277 | 0 | routeQueueForm.getMessageQueueFromForm().setServiceNamespace(null); |
278 | 0 | routeQueueForm.getMessageQueueFromForm().setMethodName(null); |
279 | 0 | routeQueueForm.getMessageQueueFromForm().setPayload(null); |
280 | 0 | routeQueueForm.getMessageQueueFromForm().setMethodCall(null); |
281 | 0 | routeQueueForm.setExistingQueueDate(null); |
282 | 0 | routeQueueForm.setNewQueueDate(null); |
283 | 0 | return mapping.findForward("basic"); |
284 | |
} |
285 | |
|
286 | |
public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
287 | |
HttpServletResponse response) throws Exception { |
288 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
289 | 0 | routeQueueForm.setMessageQueueFromForm(routeQueueForm.getMessageQueueFromDatabase()); |
290 | 0 | routeQueueForm.setMessageQueueFromDatabase(null); |
291 | 0 | getRouteQueueService().delete(routeQueueForm.getMessageQueueFromForm()); |
292 | 0 | ActionMessages messages = new ActionMessages(); |
293 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("routequeue.RouteQueueService.deleted", routeQueueForm |
294 | |
.getMessageQueueFromForm().getRouteQueueId().toString())); |
295 | 0 | saveMessages(request, messages); |
296 | 0 | routeQueueForm.setMessageId(null); |
297 | 0 | establishRequiredState(request, form); |
298 | 0 | return mapping.findForward("report"); |
299 | |
} |
300 | |
|
301 | |
public ActionForward executeMessageFetcher(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
302 | |
HttpServletResponse response) throws Exception { |
303 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
304 | 0 | ActionMessages messages = new ActionMessages(); |
305 | 0 | if (routeQueueForm.getMaxMessageFetcherMessages() == null || routeQueueForm.getMaxMessageFetcherMessages() <= 0) { |
306 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("routequeue.RouteQueueService.invalidMessages", routeQueueForm.getMaxMessageFetcherMessages())); |
307 | |
} |
308 | 0 | if (!messages.isEmpty()) { |
309 | 0 | saveMessages(request, messages); |
310 | 0 | return mapping.findForward("report"); |
311 | |
} |
312 | 0 | new MessageFetcher(routeQueueForm.getMaxMessageFetcherMessages()).run(); |
313 | 0 | return mapping.findForward("report"); |
314 | |
} |
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
@Override |
323 | |
public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm form) throws Exception { |
324 | 0 | request.setAttribute("rice_constant", getServlet().getServletContext().getAttribute("RiceConstants")); |
325 | 0 | request.setAttribute("ksb_constant", getServlet().getServletContext().getAttribute("KSBConstants")); |
326 | 0 | MessageQueueForm routeQueueForm = (MessageQueueForm) form; |
327 | 0 | routeQueueForm.setMyIpAddress(RiceUtilities.getIpNumber()); |
328 | 0 | routeQueueForm.setMyServiceNamespace(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.SERVICE_NAMESPACE)); |
329 | 0 | routeQueueForm.setMessagePersistence(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGE_PERSISTENCE)); |
330 | 0 | routeQueueForm.setMessageDelivery(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGE_DELIVERY)); |
331 | 0 | routeQueueForm.setMessageOff(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGING_OFF)); |
332 | 0 | List<ServiceInfo> services = KSBServiceLocator.getServiceRegistry().fetchAll(); |
333 | 0 | if (routeQueueForm.getMessageId() != null) { |
334 | 0 | PersistedMessageBO rq = getRouteQueueService().findByRouteQueueId(routeQueueForm.getMessageId()); |
335 | 0 | if (rq != null) { |
336 | 0 | routeQueueForm.setExistingQueueDate(RiceConstants.getDefaultDateFormat().format(new Date())); |
337 | 0 | routeQueueForm.setMessageQueueFromDatabase(rq); |
338 | |
|
339 | 0 | String serviceName = rq.getServiceName(); |
340 | 0 | for (ServiceInfo serviceInfo : services) { |
341 | 0 | if (serviceInfo.getServiceName().equals(serviceName)) { |
342 | 0 | routeQueueForm.getIpAddresses().add( |
343 | |
new ConcreteKeyValue(serviceInfo.getServerIp(), serviceInfo.getServerIp())); |
344 | |
} |
345 | |
} |
346 | 0 | } else { |
347 | 0 | ActionMessages messages = new ActionMessages(); |
348 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( |
349 | |
"messagequeue.RouteQueueService.queuedDocumentNotFound", routeQueueForm.getMessageId().toString())); |
350 | 0 | return messages; |
351 | |
} |
352 | 0 | routeQueueForm.setMessageId(null); |
353 | 0 | } else if (!"clear".equalsIgnoreCase(request.getParameter("methodToCall"))) { |
354 | 0 | List<PersistedMessageBO> queueEntries = findRouteQueues(request, routeQueueForm, routeQueueForm.getMaxRows() + 1); |
355 | 0 | if (queueEntries.size() > 0) { |
356 | 0 | Collections.sort(queueEntries, new Comparator() { |
357 | 0 | private Comparator comp = new ComparableComparator(); |
358 | |
|
359 | |
@Override |
360 | |
public int compare(Object object1, Object object2) { |
361 | 0 | if (object1 == null && object2 == null) { |
362 | 0 | return 0; |
363 | 0 | } else if (object1 == null) { |
364 | 0 | return 1; |
365 | 0 | } else if (object2 == null) { |
366 | 0 | return -1; |
367 | |
} |
368 | 0 | Long id1 = ((PersistedMessageBO) object1).getRouteQueueId(); |
369 | 0 | Long id2 = ((PersistedMessageBO) object2).getRouteQueueId(); |
370 | |
|
371 | |
try { |
372 | 0 | return this.comp.compare(id1, id2); |
373 | 0 | } catch (Exception e) { |
374 | 0 | return 0; |
375 | |
} |
376 | |
} |
377 | |
}); |
378 | |
} |
379 | 0 | routeQueueForm.setMessageQueueRows(queueEntries); |
380 | |
} |
381 | 0 | return null; |
382 | |
} |
383 | |
|
384 | |
protected List<PersistedMessageBO> findRouteQueues(HttpServletRequest request, MessageQueueForm routeQueueForm, int maxRows) { |
385 | 0 | List<PersistedMessageBO> routeQueues = new ArrayList<PersistedMessageBO>(); |
386 | |
|
387 | |
|
388 | 0 | if (StringUtils.isBlank(routeQueueForm.getFilterApplied())) { |
389 | 0 | routeQueues.addAll(getRouteQueueService().findAll(maxRows)); |
390 | |
} |
391 | |
|
392 | |
|
393 | |
else { |
394 | 0 | if (!StringUtils.isBlank(routeQueueForm.getRouteQueueIdFilter())) { |
395 | 0 | if (!NumberUtils.isNumber(routeQueueForm.getRouteQueueIdFilter())) { |
396 | |
|
397 | 0 | throw new RuntimeException("Message Id must be a number."); |
398 | |
} |
399 | |
} |
400 | |
|
401 | 0 | Map<String, String> criteriaValues = new HashMap<String, String>(); |
402 | 0 | String key = null; |
403 | 0 | String value = null; |
404 | 0 | String trimmedKey = null; |
405 | 0 | for (Iterator iter = request.getParameterMap().keySet().iterator(); iter.hasNext();) { |
406 | 0 | key = (String) iter.next(); |
407 | 0 | if (key.endsWith(KSBConstants.ROUTE_QUEUE_FILTER_SUFFIX)) { |
408 | 0 | value = request.getParameter(key); |
409 | 0 | if (StringUtils.isNotBlank(value)) { |
410 | 0 | trimmedKey = key.substring(0, key.indexOf(KSBConstants.ROUTE_QUEUE_FILTER_SUFFIX)); |
411 | 0 | criteriaValues.put(trimmedKey, value); |
412 | |
} |
413 | |
} |
414 | |
} |
415 | 0 | routeQueues.addAll(getRouteQueueService().findByValues(criteriaValues, maxRows)); |
416 | |
} |
417 | 0 | return routeQueues; |
418 | |
} |
419 | |
|
420 | |
private MessageQueueService getRouteQueueService() { |
421 | 0 | return KSBServiceLocator.getRouteQueueService(); |
422 | |
} |
423 | |
|
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
protected AsynchronousCall unwrapPayload(PersistedMessageBO message) { |
435 | 0 | if (message == null || message.getPayload() == null) { |
436 | 0 | return null; |
437 | |
} |
438 | 0 | String encodedPayload = message.getPayload().getPayload(); |
439 | 0 | if (StringUtils.isBlank(encodedPayload)) { |
440 | 0 | return null; |
441 | |
} |
442 | 0 | Object decodedPayload = null; |
443 | 0 | if (encodedPayload != null) { |
444 | 0 | decodedPayload = KSBServiceLocator.getMessageHelper().deserializeObject(encodedPayload); |
445 | |
} |
446 | |
|
447 | 0 | if ((decodedPayload != null) && !(decodedPayload instanceof AsynchronousCall)) { |
448 | 0 | throw new IllegalArgumentException("PersistedMessageBO payload was not of the expected class. " + "Expected was [" |
449 | |
+ AsynchronousCall.class.getName() + "], actual was: [" + decodedPayload.getClass().getName() + "]"); |
450 | |
} |
451 | 0 | return (AsynchronousCall) decodedPayload; |
452 | |
} |
453 | |
|
454 | |
} |