mirror of https://github.com/apache/activemq.git
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:
parent
1a7fe702dc
commit
57b16b1c31
|
@ -18,12 +18,10 @@ package org.apache.activemq.web.controller;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.Message;
|
import javax.jms.Message;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.activemq.command.ActiveMQDestination;
|
import org.apache.activemq.command.ActiveMQDestination;
|
||||||
import org.apache.activemq.web.BrokerFacade;
|
import org.apache.activemq.web.BrokerFacade;
|
||||||
import org.apache.activemq.web.DestinationFacade;
|
import org.apache.activemq.web.DestinationFacade;
|
||||||
|
@ -66,7 +64,8 @@ public class SendMessage extends DestinationFacade implements Controller {
|
||||||
return redirectToBrowseView();
|
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) {
|
if (jmsMessageCount <= 1) {
|
||||||
jmsMessageCount = 1;
|
jmsMessageCount = 1;
|
||||||
}
|
}
|
||||||
|
@ -177,34 +176,56 @@ public class SendMessage extends DestinationFacade implements Controller {
|
||||||
Map map = request.getParameterMap();
|
Map map = request.getParameterMap();
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
|
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
|
||||||
Map.Entry entry = (Map.Entry)iter.next();
|
Map.Entry entry = (Map.Entry) iter.next();
|
||||||
String name = (String)entry.getKey();
|
String name = (String) entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
if (isValidPropertyName(name)) {
|
if (isValidPropertyName(name)) {
|
||||||
if (value instanceof String[]) {
|
if (value instanceof String[]) {
|
||||||
String[] array = (String[])value;
|
String[] array = (String[]) value;
|
||||||
if (array.length > 0) {
|
if (array.length > 0) {
|
||||||
value = array[0];
|
value = array[0];
|
||||||
} else {
|
} else {
|
||||||
value = null;
|
value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (value instanceof String) {
|
if ((name.equals("AMQ_SCHEDULED_DELAY") || name.equals("AMQ_SCHEDULED_PERIOD"))) {
|
||||||
String text = value.toString().trim();
|
if (value != null) {
|
||||||
if (text.length() == 0) {
|
String str = value.toString().trim();
|
||||||
value = null;
|
if (str.length() > 0) {
|
||||||
} else {
|
message.setLongProperty(name, Long.parseLong(str));
|
||||||
value = text;
|
}
|
||||||
|
}
|
||||||
|
} 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) {
|
protected boolean isValidPropertyName(String name) {
|
||||||
// allow JMSX extensions or non JMS properties
|
// allow JMSX extensions or non JMS properties
|
||||||
return name.startsWith("JMSX") || !name.startsWith("JMS");
|
return name.startsWith("JMSX") || !name.startsWith("JMS");
|
||||||
|
|
|
@ -107,10 +107,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label">
|
<td class="label">
|
||||||
<label for="AMQ_SCHEDULED_START_TIME">Scheduled start(ms)</label>
|
<label for="AMQ_SCHEDULED_DELAY">delay(ms)</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form:text name="AMQ_SCHEDULED_START_TIME"/>
|
<form:text name="AMQ_SCHEDULED_DELAY"/>
|
||||||
</td>
|
</td>
|
||||||
<td class="label">
|
<td class="label">
|
||||||
<label for="AMQ_SCHEDULED_PERIOD">Time(ms) to wait before scheduling again</label>
|
<label for="AMQ_SCHEDULED_PERIOD">Time(ms) to wait before scheduling again</label>
|
||||||
|
|
Loading…
Reference in New Issue