Added cron support for scheduled delivery - this is further enhancements for

https://issues.apache.org/activemq/browse/AMQ-451

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@908869 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2010-02-11 08:22:31 +00:00
parent 1a7fe702dc
commit 57b16b1c31
2 changed files with 39 additions and 18 deletions

View File

@ -18,12 +18,10 @@ package org.apache.activemq.web.controller;
import java.util.Iterator;
import java.util.Map;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.web.BrokerFacade;
import org.apache.activemq.web.DestinationFacade;
@ -66,7 +64,8 @@ public class SendMessage extends DestinationFacade implements Controller {
return redirectToBrowseView();
}
protected void sendMessages(HttpServletRequest request, WebClient client, ActiveMQDestination dest) throws JMSException {
protected void sendMessages(HttpServletRequest request, WebClient client, ActiveMQDestination dest)
throws JMSException {
if (jmsMessageCount <= 1) {
jmsMessageCount = 1;
}
@ -177,34 +176,56 @@ public class SendMessage extends DestinationFacade implements Controller {
Map map = request.getParameterMap();
if (map != null) {
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry)iter.next();
String name = (String)entry.getKey();
Map.Entry entry = (Map.Entry) iter.next();
String name = (String) entry.getKey();
Object value = entry.getValue();
if (isValidPropertyName(name)) {
if (value instanceof String[]) {
String[] array = (String[])value;
String[] array = (String[]) value;
if (array.length > 0) {
value = array[0];
} else {
value = null;
}
}
if (value instanceof String) {
String text = value.toString().trim();
if (text.length() == 0) {
value = null;
} else {
value = text;
if ((name.equals("AMQ_SCHEDULED_DELAY") || name.equals("AMQ_SCHEDULED_PERIOD"))) {
if (value != null) {
String str = value.toString().trim();
if (str.length() > 0) {
message.setLongProperty(name, Long.parseLong(str));
}
}
} else if (name.equals("AMQ_SCHEDULED_REPEAT")) {
if (value != null) {
String str = value.toString().trim();
if (str.length() > 0) {
message.setIntProperty(name, Integer.parseInt(str));
}
}
} else if (name.equals("AMQ_SCHEDULED_CRON")) {
if (value != null) {
String str = value.toString().trim();
if (str.length() > 0) {
message.setStringProperty(name, str);
}
}
} else {
if (value instanceof String) {
String text = value.toString().trim();
if (text.length() == 0) {
value = null;
} else {
value = text;
}
}
if (value != null) {
message.setObjectProperty(name, value);
}
}
if (value != null) {
message.setObjectProperty(name, value);
}
}
}
}
}
protected boolean isValidPropertyName(String name) {
// allow JMSX extensions or non JMS properties
return name.startsWith("JMSX") || !name.startsWith("JMS");

View File

@ -107,10 +107,10 @@
</tr>
<tr>
<td class="label">
<label for="AMQ_SCHEDULED_START_TIME">Scheduled start(ms)</label>
<label for="AMQ_SCHEDULED_DELAY">delay(ms)</label>
</td>
<td>
<form:text name="AMQ_SCHEDULED_START_TIME"/>
<form:text name="AMQ_SCHEDULED_DELAY"/>
</td>
<td class="label">
<label for="AMQ_SCHEDULED_PERIOD">Time(ms) to wait before scheduling again</label>