Class TestMessageListener

  • All Implemented Interfaces:
    javax.jms.MessageListener

    public class TestMessageListener
    extends java.lang.Object
    implements javax.jms.MessageListener
    A simple message listener that collects the messages given to it and lets you query them
    • Method Detail

      • onMessage

        public void onMessage​(javax.jms.Message msg)
        Specified by:
        onMessage in interface javax.jms.MessageListener
      • getReceived

        public NetarkivetMessage getReceived()
        Get the last message received.
        Returns:
        The last message received by the listener.
        Throws:
        java.lang.IndexOutOfBoundsException - if no messages have been received.
      • getNumReceived

        public int getNumReceived()
        Return the number of messages received so far.
        Returns:
        the number of messages received so far
      • reset

        public void reset()
        Reset the list of messages returned.
      • getNumOk

        public int getNumOk()
        Returns the number of received messages that were ok.
        Returns:
        the number of received messages that were ok
      • getNumNotOk

        public int getNumNotOk()
        Returns the number of received messages that were not ok.
        Returns:
        the number of received messages that were not ok
      • getLastInstance

        public NetarkivetMessage getLastInstance​(java.lang.Class msgClass)
        Looks up the messages that are instances of the given class.
        Parameters:
        msgClass - A subclass of NetarkivetMessage, e.g. BatchMessage.class;
        Returns:
        The instance that was most recently received, or null if no messages of the specified type has been received.