Skip to content

Consumer Only Retrieves some Messages from Queue When More Are Available #223

@kajal-bhandare

Description

@kajal-bhandare

Describe the bug
When using the IBM MQ Golang library, I have two mainframe queues configured on the same channel and connection. With WaitInterval set to -1, my consumer is able to retrieve all 10 messages from the first queue. However, when I put 15 messages on the second queue, the consumer only retrieves 10 messages, even though 15 were sent.

To Reproduce
Steps to reproduce the behavior:

  1. Set up two mainframe queues on the same channel and connection.
  2. Use the IBM MQ Golang library to consume messages with WaitInterval = -1.
  3. Put 10 messages on Queue 1 and observe that all 10 are consumed.
  4. Put 15 messages on Queue 2 and observe that only 10 are consumed.

same logic is for both queue consumer
for {
// Message Descriptor
msg := ibmmq.NewMQMD()

	// Get Message Options
	gmo := ibmmq.NewMQGMO()
	gmo.Options = ibmmq.MQGMO_WAIT | ibmmq.MQGMO_NO_SYNCPOINT | ibmmq.MQGMO_CONVERT
	gmo.WaitInterval = ibmmq.MQWI_UNLIMITED // Wait indefinitely for a message
	logger.Debug("Listening WIVS...")
	msg.CodedCharSetId = 37
	// Buffer to store the message
	buffer := make([]byte, 1024) // Adjust size based on expected message size

	// Get the message
	dataLen, err := MQObject.Get(msg, gmo, buffer)
	if err != nil {
		// Handle specific MQ errors
		mqErr, ok := err.(*ibmmq.MQReturn)
		if ok && mqErr.MQRC == ibmmq.MQRC_NO_MSG_AVAILABLE {
			// No message available, continue listening
			logger.Debug("No message available, continuing to listen...wivs1")
			continue
		}
		if mqErr.MQCC == ibmmq.MQRC_HOBJ_ERROR {
			logger.Error("MQ object Closed WIVS")
			break
		}
		logger.Error("Error getting message: ", zap.Error(err))
		break
	}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions