1 Reply Latest reply: Jul 27, 2013 3:28 AM by pabhat RSS

    JMS client receives AQ messages asynchronously with a delay of 15 seconds

    user2885917
      I have written a stand alone (Java SE 1.6) JMS client program to consume AQ's messages via Oracle JMS API (aqapi.jar). The queue is a multiple consumer queue, and i just created one subscriber on it. My JMS client program receives messages asynchronously by setting the MessageListener using the setMessageListener method.

      Watching the work of the program, I found significant delays in receiving messages that are up to several seconds. When I turned on the diagnostic trace, I found that in the absence of messages listener (AQjmsSimpleScheduler) gradually increases the delay time up to 15 seconds:


      Thread-1 [Mon May 06 22:14:23 MSK 2013] AQjmsSimpleScheduler.feedData: Got a non null message, the sleep time is reset to 0
      Thread-1 [Mon May 06 22:14:23 MSK 2013] AQjmsListenerWorker.run: sleep 0 millisecond.

      Thread-1 [Mon May 06 22:14:23 MSK 2013] AQjmsSimpleScheduler.feedData: Got a null message, the sleep time is doubled to 1000
      Thread-1 [Mon May 06 22:14:23 MSK 2013] AQjmsListenerWorker.run: sleep 1000 millisecond.
      Thread-1 [Mon May 06 22:14:23 MSK 2013] AQjmsListenerWorker.doSleep: try to wait for 1000 milliseconds

      Thread-1 [Mon May 06 22:14:24 MSK 2013] AQjmsSimpleScheduler.feedData: Got a null message, the sleep time is doubled to 2000
      Thread-1 [Mon May 06 22:14:24 MSK 2013] AQjmsListenerWorker.run: sleep 2000 millisecond.
      Thread-1 [Mon May 06 22:14:24 MSK 2013] AQjmsListenerWorker.doSleep: try to wait for 2000 milliseconds

      Thread-1 [Mon May 06 22:14:26 MSK 2013] AQjmsSimpleScheduler.feedData: Got a null message, the sleep time is doubled to 4000
      Thread-1 [Mon May 06 22:14:26 MSK 2013] AQjmsListenerWorker.run: sleep 4000 millisecond.
      Thread-1 [Mon May 06 22:14:26 MSK 2013] AQjmsListenerWorker.doSleep: try to wait for 4000 milliseconds

      Thread-1 [Mon May 06 22:14:30 MSK 2013] AQjmsSimpleScheduler.feedData: Got a null message, the sleep time is doubled to 8000
      Thread-1 [Mon May 06 22:14:30 MSK 2013] AQjmsListenerWorker.run: sleep 8000 millisecond.
      Thread-1 [Mon May 06 22:14:30 MSK 2013] AQjmsListenerWorker.doSleep: try to wait for 8000 milliseconds

      Thread-1 [Mon May 06 22:14:38 MSK 2013] AQjmsSimpleScheduler.feedData: Got a null message, the sleep time is doubled to 15000
      Thread-1 [Mon May 06 22:14:38 MSK 2013] AQjmsListenerWorker.run: sleep 15000 millisecond.
      Thread-1 [Mon May 06 22:14:38 MSK 2013] AQjmsListenerWorker.doSleep: try to wait for 15000 milliseconds

      Thread-1 [Mon May 06 22:14:53 MSK 2013] AQjmsSimpleScheduler.feedData: Got a null message, the sleep time is doubled to 15000
      Thread-1 [Mon May 06 22:14:53 MSK 2013] AQjmsListenerWorker.run: sleep 15000 millisecond.
      Thread-1 [Mon May 06 22:14:53 MSK 2013] AQjmsListenerWorker.doSleep: try to wait for 15000 milliseconds


      Thus, in the worst case, the delay between placing the message in the queue and receiving it by the JMS client is 15 seconds.

      Can I control this latency? For example, I would like to explicitly set the levels of the time delays. Have any ideas?

      Thank you very much for your advices.
        • 1. Re: JMS client receives AQ messages asynchronously with a delay of 15 seconds
          pabhat

          In your JMS client, you can set the system properties "oracle.jms.minSleepTime" and "oracle.jms.maxSleepTime"

           

          For example,

              System.setProperty("oracle.jms.minSleepTime", "100");

              System.setProperty("oracle.jms.maxSleepTime", "4000");

           

          In this case, the listener will wait for 100ms to start with and the sleep time will be doubled if there is no new message - 200, 400, 800, 1600, 3200, and 4000 ms. The sleep time won't go beyond 4000ms and will be reset to 0 whenever there is a new message.