3.1.7.3.2 Seek Available Message Position

This event MUST be generated with the following arguments:

  • iInitialPosition: A reference to the MessagePosition (section 3.1.1.11) ADM element instance from which iteration commences.

  • iQueue: A reference to the Queue (section 3.1.1.2) ADM element instance in which the iteration occurs.

  • iPeekOperation: A Boolean that indicates if this seek is for a non-destructive read operation.

  • iSeekDirection (Optional): An enumeration that defines the direction in which to seek. This enumeration MUST have one of the following values:

    • Forward (default)

    • Backward

Return Value:

  • rMessagePosition: A reference to a MessagePosition ADM element instance that is available in iQueue or the special End position defined for the MessagePositionList ADM attribute of a Queue ADM element instance. The End position indicates that no message was available.

The queue manager MUST perform the following actions to process this event:

  • Define iIterator as a reference to a MessagePosition ADM element instance for the purpose of iterating iQueue.MessagePositionList and set it to iInitialPosition.

  • If iSeekDirection is Forward or if the iSeekDirection argument is not supplied:

    • If iIterator is equivalent to the StartMessagePosition ADM element instance defined for iQueue.MessagePositionList:

      • Set iIterator to iQueue.MessagePositionList.Head

    • Else:

      • Set iIterator to iInitialPosition.Next.

    • While iIterator is not equivalent to iQueue.MessagePositionList.End and iIterator.State is not Available:

      • If iIterator.State is Locked and iPeekOperation is True and iIterator.MessageReference.AllowPeekWhenLocked is True:

        • Set rMessagePosition to iIterator

        • Take no further action

      • Set iIterator to iIterator.Next.

  • Else:

    • If iIterator is equivalent to the EndMessagePosition ADM element instance defined for iQueue.MessagePositionList:

      • Set iIterator to iQueue.MessagePositionList.Tail

    • Else:

      • Set iIterator to iInitialPosition.Previous.

    • While iIterator is not equivalent to iQueue.MessagePositionList.Start and iIterator.State is not Available:

      • If iIterator.State is Locked and iPeekOperation is True and iIterator.MessageReference.AllowPeekWhenLocked is True:

        • Set rMessagePosition to iIterator

        • Take no further action

      • Set iIterator to iIterator.Previous.

  • Set rMessagePosition to iIterator.