activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dejan Bosanac (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (AMQ-5170) Selectors in AMQ through REST does not work properly
Date Mon, 26 May 2014 11:24:01 GMT

    [ https://issues.apache.org/jira/browse/AMQ-5170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14008764#comment-14008764
] 

Dejan Bosanac edited comment on AMQ-5170 at 5/26/14 11:23 AM:
--------------------------------------------------------------

This already works, you just need to pass the selector as a HTTP header and not a parameter.
See

http://activemq.apache.org/rest.html#REST-Consumingwithselectors

for more information.

For the given example, I'd also suggest using clientId option as it will give more control
over subscribing/unsubscribing from the queue without using sessions.

So for this particular example, two producers created like this

{code}wget -qO- --user admin --password admin --header="selector: prop=1" 'http://localhost:8161/api/message/test?type=queue&clientId=consumer1'
wget -qO- --user admin --password admin --header="selector: prop=2" 'http://localhost:8161/api/message/test?type=queue&clientId=consumer2'{code}

should do the trick


was (Author: dejanb):
This already works, you just need to pass the selector as a HTTP header and not a parameter.
See

http://activemq.apache.org/rest.html#REST-Consumingwithselectors

for more information.

For the given example, I'd also suggest using clientId option as it will give more control
over subscribing/unsubscribing from the queue without using sessions.

So for this particular example, two producers created like this

{code}wget -qO- --user admin --password admin --header="selector: prop=1" 'http://localhost:8161/api/message/test?type=queue\&clientId=consumer1'
wget -qO- --user admin --password admin --header="selector: prop=2" 'http://localhost:8161/api/message/test?type=queue\&clientId=consumer2'{code}

should do the trick

> 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
>            Assignee: Dejan Bosanac
>
> 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)

Mime
View raw message