You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Joe Luo (JIRA)" <ji...@apache.org> on 2014/05/02 21:39:15 UTC

[jira] [Created] (AMQ-5170) Selectors in AMQ through REST does not work properly

Joe Luo created AMQ-5170:
----------------------------

             Summary: Selectors in AMQ through REST does not work properly
                 Key: AMQ-5170
                 URL: https://issues.apache.org/jira/browse/AMQ-5170
             Project: ActiveMQ
          Issue Type: Bug
    Affects Versions: 5.8.0
         Environment: Tested with the following client utilities:
wget (GNU Wget 1.11.4)
Advanced REST client 3.1.7 (Google Chrome extension)
RestClient 2.0.3 (Firefox extension)
            Reporter: Joe Luo


ActiveMQ seems to ignore the selector query specified and works on initial get but will not deliver messages on subsequent requests.

Steps to Reproduce
1. Create a queue in ActiveMQ called “test”.

2. Modify shipped ProducerTool.java with following change on the method "sendLoop":
{code}
protected void sendLoop(Session session, MessageProducer producer) throws Exception {

        for (int i = 0; i < messageCount || messageCount == 0; i++) {

            TextMessage message = session.createTextMessage(createMessageText(i));

            if (i%2 == 0) {
                message.setIntProperty("prop", 1);
            } else {
                message.setIntProperty("prop", 2);
            }

            if (verbose) {
                String msg = message.getText();
                if (msg.length() > 50) {
                    msg = msg.substring(0, 50) + "...";
                }
                System.out.println("[" + this.getName() + "] Sending message: '" + msg + "'");
            }

            producer.send(message);

            if (transacted) {
                System.out.println("[" + this.getName() + "] Committing " + messageCount + " message
s");
                session.commit();
            }
            Thread.sleep(sleepTime);
        }
    }
{code} 

3. send 5 messages to broker with following command:
{code}
ant producer -Dsubject=test -Dtopic=false -Ddurable=true -Dmax=5 -DmessageSize=50 -Duser=admin -Dpassword=admin
{code}

4. Using any REST client, specify the URL with selector: 
{code}
http://localhost:8161/api/message/test?type=queue&prop=2
{code}
and execute the consumer REST request to download the message from the event queue.

5. The first message will always get downloaded regardless of selector query whether it matches or not. Since above rest URL with the selector should not get the first message as the first message has Int Property "prop=1" which does not match the selector.

6. Then try with following rest URL from another REST client:
{code}
http://localhost:8161/api/message/test?type=queue&prop=1
{code}
Regardless of selector query or even without a selector, this client will not be able to download any message and all messages will remain in the queue.

Expected Behavior
The ActiveMQ broker should respect the message selector query when specified by the consumer application using the REST interface.  Using the steps outlined above with the openwire protocol (tcp/ip) works i.e. creating the MessageConsumer as:
{code}
MessageConsumer consumer = session.createConsumer(destination, "prop=1");
{code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)