diff --git a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java index dceb311f54..db23419a81 100644 --- a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java +++ b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java @@ -35,7 +35,7 @@ public class RestTest extends JettyTestSupport { ContentExchange contentExchange = new ContentExchange(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); contentExchange.setURL("http://localhost:8080/message/test?timeout=1000&type=queue"); - contentExchange.setRequestHeader(WebClient.SELECTOR_NAME, "test=2"); + contentExchange.setRequestHeader("selector", "test=2"); httpClient.send(contentExchange); contentExchange.waitForDone(); assertEquals("test2", contentExchange.getResponseContent()); diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java index 091a163726..ce5d6cf256 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java @@ -156,7 +156,7 @@ public class MessageListenerServlet extends MessageServletSupport { Map consumerDestinationMap = getConsumerDestinationNameMap(request); client.closeConsumer(destination); // drop any existing // consumer. - MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.SELECTOR_NAME)); + MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.selectorName)); consumer.setAvailableListener(listener); consumerIdMap.put(consumer, message); @@ -167,7 +167,7 @@ public class MessageListenerServlet extends MessageServletSupport { } else if ("unlisten".equals(type)) { Map consumerIdMap = getConsumerIdMap(request); Map consumerDestinationMap = getConsumerDestinationNameMap(request); - MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.SELECTOR_NAME)); + MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.selectorName)); consumer.setAvailableListener(null); consumerIdMap.remove(consumer); diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java index 46495fb911..3c364c425b 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java @@ -180,7 +180,7 @@ public class MessageServlet extends MessageServletSupport { LOG.debug("Receiving message(s) from: " + destination + " with timeout: " + timeout); } - MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.SELECTOR_NAME)); + MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.selectorName)); Continuation continuation = null; Listener listener = null; Message message = null; @@ -297,7 +297,7 @@ public class MessageServlet extends MessageServletSupport { LOG.debug("Receiving message(s) from: " + destination + " with timeout: " + timeout); } - MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.SELECTOR_NAME)); + MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination, request.getHeader(WebClient.selectorName)); Message message = null; // write a responds diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java index c751e87a11..59c265864a 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java @@ -355,6 +355,6 @@ public abstract class MessageServletSupport extends HttpServlet { } protected String getSelector(HttpServletRequest request) throws IOException { - return request.getHeader(WebClient.SELECTOR_NAME); + return request.getHeader(WebClient.selectorName); } } diff --git a/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java b/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java index d891afa488..40c4715b43 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java @@ -70,7 +70,7 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind public static final String CONNECTION_FACTORY_PREFETCH_PARAM = "org.apache.activemq.connectionFactory.prefetch"; public static final String CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM = "org.apache.activemq.connectionFactory.optimizeAck"; public static final String BROKER_URL_INIT_PARAM = "org.apache.activemq.brokerURL"; - public static final String SELECTOR_NAME = "org.apache.activemq.selector"; + public static final String SELECTOR_NAME = "org.apache.activemq.selectorName"; private static final Log LOG = LogFactory.getLog(WebClient.class); @@ -81,6 +81,7 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind private transient Session session; private transient MessageProducer producer; private int deliveryMode = DeliveryMode.NON_PERSISTENT; + public static String selectorName; private final Semaphore semaphore = new Semaphore(1); @@ -122,6 +123,12 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind public static void initContext(ServletContext context) { initConnectionFactory(context); context.setAttribute("webClients", new HashMap()); + if (selectorName == null) { + selectorName = context.getInitParameter(SELECTOR_NAME); + } + if (selectorName == null) { + selectorName = "selector"; + } } public int getDeliveryMode() {