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

Peter Eisenlohr commented on AMQ-4938:
--------------------------------------

Thank you very much for the fix, I can confirm it works with the above test 
case. With just one client, no messages are lost.

Here's another test case involving two distinct client IDs, but no actual race:
{code}
#
# Two clients with IDs "GETID-1" and "GETID-2"... both timeout since there are 
no messages yet
#
wget --no-http-keep-alive -q -O - 
"http://localhost:8161/api/message/TEST?type=queue&clientId=GETID-1&readTimeout=1000";
wget --no-http-keep-alive -q -O - 
"http://localhost:8161/api/message/TEST?type=queue&clientId=GETID-2&readTimeout=1000";

# Send a message:
curl -d "body=$((++i))" http://localhost:8161/api/message/TEST?type=queue; echo 
": $i"
Message sent

#
# Receive using first client ID, OK
#
wget --no-http-keep-alive -q -O - 
"http://localhost:8161/api/message/TEST?type=queue&clientId=GETID-1&readTimeout=1000";
1

#
# Send a message again:
#
curl -d "body=$((++i))" http://localhost:8161/api/message/TEST?type=queue; echo 
": $i"
Message sent

#
# Receive using first client ID, no response, not OK
#
wget --no-http-keep-alive -q -O - 
"http://localhost:8161/api/message/TEST?type=queue&clientId=GETID-1&readTimeout=1000";

# ... but with client ID 2:
wget --no-http-keep-alive -q -O - 
"http://localhost:8161/api/message/TEST?type=queue&clientId=GETID-2&readTimeout=1000";
2
{code}

Seems like round-robin still happens even after a client disconnected because 
of the read timeout. Hope this helps.

> Queue Messages lost after read timeout on REST API.
> ---------------------------------------------------
>
>                 Key: AMQ-4938
>                 URL: https://issues.apache.org/jira/browse/AMQ-4938
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.8.0, 5.9.0, 5.10.0
>         Environment: Win32, Linux
>            Reporter: Peter Eisenlohr
>            Priority: Critical
>         Attachments: AMQ-4938.patch
>
>
> I have been trying to send/receive messages via a Queue using the [REST 
> API|http://activemq.apache.org/rest.html]. While testing I found that some 
> messages got lost after a consuming request times out when no message is 
> available.
> Here is a transcript of the test case I used:
> {code}
> #
> # OK: send first, consume later
> #
> $ curl -d "body=message" "http://localhost:8161/api/message/TEST?type=queue";
> Message sent
> $ wget --no-http-keep-alive -q -O - 
> "http://localhost:8161/api/message/TEST?type=queue&clientId=GETID&readTimeout=1000";
> message
> #
> # OK: start consuming, then send (within timeout)
> #
> $ wget --no-http-keep-alive -q -O - 
> "http://localhost:8161/api/message/TEST?type=queue&clientId=GETID&readTimeout=5000"&;
> [1] 5172
> $ curl -d "body=message" "http://localhost:8161/api/message/TEST?type=queue";
> messageMessage sent[1]+  Fertig                  wget --no-http-keep-alive -q 
> -O - 
> "http://localhost:8161/api/message/TEST?type=queue&clientId=GETID&readTimeout=5000";
> #
> # NOK: start consuming, wait for timeout, then send and consume again
> #
> $ wget --no-http-keep-alive -q -O - 
> "http://localhost:8161/api/message/TEST?type=queue&clientId=GETID&readTimeout=5000";
> $ curl -d "body=message" "http://localhost:8161/api/message/TEST?type=queue";
> Message sent
> $ wget --no-http-keep-alive -q -O - 
> "http://localhost:8161/api/message/TEST?type=queue&clientId=GETID&readTimeout=5000";
> {code}
> The last *wget* returns after the given read timeout without any message. 
> When looking at the managament console, the message has been consumed.
> I tested this with 5.8.0 on linux as well as with 5.8.0, 5.9.0 and a freshly 
> built 5.10.0 on windows.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to