0 Replies Latest reply on Nov 9, 2009 4:25 PM by Tim Fox

    Replaced receive() with receiveImmediate()

    Tim Fox Master

      Many tests were doing this kind of thing:

      
      assertNull(consumer.receive(1000))
      


      Now that receive semantics are synchronous, these can be replaced with:

      assertNull(consumer.receiveImmediate())
      


      Summary:

      a) If you expect to receive a message in a test (e.g. assertNotNull), do not use a small timeout since this makes the test non deterministic due to thread scheduling, garbage collection etc. There is no harm in using a large timeout because in the normal situation the message will be received quickly anyway

      b) If you do not expect to receive the message (ie. assertNull), then use receiveImmediate() (or receiveNoWait in JMS)

      I have refactored the tests to do the above and I have reduced test suite execution time by 20 minutes :)

      (It was 90 minutes on my box, now it is 70).