Topic
5 replies Latest Post - ‏2013-01-29T10:47:10Z by SystemAdmin
SystemAdmin
SystemAdmin
8523 Posts
ACCEPTED ANSWER

Pinned topic MQQueue - CurrentDepth gives 2068

‏2013-01-24T18:05:41Z |
I have the following VB.NET code in a test tool to retrieve the CurrentDepth. I need to this to loop through the messages in the queue and list them for further action.

Dim MyMQOpenOptions As Integer = MQC.MQOO_INQUIRE + MQC.MQOO_BROWSE
Dim MyMQQueue As MQQueue = MyMQManager.AccessQueue(MyMQQueueName, MyMQOpenOptions)
Dim MyDepth As Integer = MyMQQueue.CurrentDepth

I keep on getting a 2068 (MQRC_SELECTOR_NOT_FOR_TYPE).

Thanks for the help
Rico
Updated on 2013-01-29T10:47:10Z at 2013-01-29T10:47:10Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    8523 Posts
    ACCEPTED ANSWER

    Re: MQQueue - CurrentDepth gives 2068

    ‏2013-01-24T23:12:04Z  in response to SystemAdmin
    App programs should generally not be designed so that they need to know current depth of a queue. This is a very ephemeral quantity. One millisecond it may be zero, the next millisecond it may be 1000.

    If you want to loop through messages, the app should contain a loop to get messages and exit the loop if MQ returns that there are no more messages on the queue.

    If the design requires a list to be made for further action, the initial loop should "browse" all the messages and store the MessageId or CorrelationId (or some other unique property) in an array or database. A subsequent loop then takes action by destructively getting particular messages using the unique property.

    HTH, G.
    • SystemAdmin
      SystemAdmin
      8523 Posts
      ACCEPTED ANSWER

      Re: MQQueue - CurrentDepth gives 2068

      ‏2013-01-25T06:32:32Z  in response to SystemAdmin
      Thanks for the reply. I still dont know why I am getting the 2068.
      If I dont know the number of messages on the queue, it means that the loop will be infinite. Is that a correct?
      • fjb_saper
        fjb_saper
        167 Posts
        ACCEPTED ANSWER

        Re: MQQueue - CurrentDepth gives 2068

        ‏2013-01-26T19:20:48Z  in response to SystemAdmin
        No the loop is not infinite.
        The loop needs to exit when there is no more messages on the queue.
        This condition is returned in the reason code. Or by returning a null message (depending on API used).

        You may need to review your design
      • fjb_saper
        fjb_saper
        167 Posts
        ACCEPTED ANSWER

        Re: MQQueue - CurrentDepth gives 2068

        ‏2013-01-26T19:23:45Z  in response to SystemAdmin
        And remember you cannot receive messages from some type of queues, nor can you retrieve a queue depth for them. This is the reason you are receiving the return code /reason code you are experiencing.
      • SystemAdmin
        SystemAdmin
        8523 Posts
        ACCEPTED ANSWER

        Re: MQQueue - CurrentDepth gives 2068

        ‏2013-01-29T10:47:10Z  in response to SystemAdmin
        Remember that the selector in question, MQIA_CURRENT_DEPTH, only applies to Local queues (see CurrentQDepth (MQLONG)

        However, the other posters are correct, you should not be designing your application to use the current depth value to drive your loop. Instead, you should get (or browse) the next message until the queue manager reports MQRC_NO_MSG_AVAILABLE (2033), then you can exit your loop.

        Take a look at the code in sample amqsget0.c for a starting point if you're unsure.

        Cheers
        Morag