Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-5340

QueueBrowser with expired messages hangs until woken by expired messages background job

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 5.9.0, 5.10.0
    • 5.12.0
    • Broker

    Description

      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.

      Attachments

        1. AMQ5340BrowsingWithSpring.java
          5 kB
          Christopher L. Shannon
        2. AMQ5340BrowsingPerformanceBugCorrected.java
          6 kB
          Vermeulen
        3. AMQ5340BrowsingPerformanceBug.java
          5 kB
          Vermeulen

        Issue Links

          Activity

            People

              Unassigned Unassigned
              slowstrider Vermeulen
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: