You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/07/06 13:51:04 UTC

[jira] [Commented] (AMQ-5340) QueueBrowser with expired messages hangs until woken by expired messages background job

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

ASF GitHub Bot commented on AMQ-5340:
-------------------------------------

GitHub user cshannon opened a pull request:

    https://github.com/apache/activemq/pull/127

    https://issues.apache.org/jira/browse/AMQ-5340

    A QueueBrowser no longer checks expiry on messages to prevent a
    browser from hanging in between the hasMoreElements check and actually
    getting a message.  This means that if messages were in the queue when
    the browser started it will receive messages even if they are now
    expired. Even though the browser will get the expired message, the
    broker will still expire it to prevent future access to it.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cshannon/activemq AMQ-5340

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/activemq/pull/127.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #127
    
----
commit ebac24a95870fda9de760709ffb5533adaa5c7f7
Author: Christopher L. Shannon <ch...@gmail.com>
Date:   2015-07-06T02:11:23Z

    https://issues.apache.org/jira/browse/AMQ-5340
    
    A QueueBrowser no longer checks expiry on messages to prevent a
    browser from hanging in between the hasMoreElements check and actually
    getting a message.  This means that if messages were in the queue when
    the browser started it will receive messages even if they are now
    expired. Even though the browser will get the expired message, the
    broker will still expire it to prevent future access to it.
    
    Thanks to Henno Vermeulen for providing a test case.

----


> QueueBrowser with expired messages hangs until woken by expired messages background job
> ---------------------------------------------------------------------------------------
>
>                 Key: AMQ-5340
>                 URL: https://issues.apache.org/jira/browse/AMQ-5340
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.9.0, 5.10.0
>            Reporter: Vermeulen
>            Priority: Critical
>              Labels: QueueBrowser
>         Attachments: AMQ5340BrowsingPerformanceBug.java, AMQ5340BrowsingPerformanceBugCorrected.java, AMQ5340BrowsingWithSpring.java
>
>
> I would expect browsing a queue with only a few messages to not take a long time. Indeed it normally takes only a few ms. in my application. But sometimes the ActiveMQQueueBrowser hangs for up to 30 seconds at method before returning!
> When the issue occurs, the loop in hasMoreElements() calls waitForMessage() multiple times which times out after 2s at semaphore.wait(2000) without receiving any message from the broker. I found that when the broker's background job that checks for expired messages runs, the browser happens to be woken even if there are no expired messages. So setting the expireMessagesPeriod to a low value (e.g. 200ms) is a good workaround for this issue, but this is quite brittle because it uses internal broker implementation that may not even be related to the issue!
> To reproduce:
> - (this is what I do in my application) create a queue, send a few message with an expiration time of 10 seconds and repeatedly browse it until it is empty. If I browse the queue after these 10 seconds have passed, the issue occurs!
> - I can always reproduce the issue by running AMQ580BrowsingBug from the related bug report AMQ-4595: this browsing test seems to always hang. I slightly adjusted the test so you can easily change the expired messages period and see the runtime differ when changing this.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)