3

Has anyone worked with MQ from RPG? The problem is as follows. There are several messages in the queue. All of them are with RFH2 header. Each header contains a set of NameValueData. I am creating a Message Handle and passing it to MQGET. Then I retrieve Properties using MQINQMP. Question. When I read several messages in a loop, using the same Message Handle instance for all (without freeing it and re-creating it for each message), will I have memory leaks?

Morag Hughson
  • 7,255
  • 15
  • 44
  • This seems like a loaded question - are you seeing the possibility of memory leaks and have identified this as a possibility? Clearly IBM did not design the interface to have memory leaks, but there may be a defect in there that has not been fixed. – Morag Hughson Aug 19 '21 at 11:08

1 Answers1

4

The IBM MQ Message Properties API is designed to be used in the following way.

MQOPEN
MQCRTMH

start-loop

MQGET
MQINQMP

end-loop

MQCLOSE
MQDLTMH

You can see this demonstrated in the IBM supplied 'C' sample amqsbcg0.c. I know your question is for RPG, but the underlying API is meant to work the same for all languages.

Morag Hughson
  • 7,255
  • 15
  • 44
  • 1
    Morag, great thanks! This is exactly what I wanted to know. You gave just that case of using MQINQMP which I assume in my case. Unfortunately, the original examples of using MQ are not available to me (we did not install them when installing MQ), and this issue is not covered in the documentation. Calling MQCRTMH before every MQGET and MQDLTMH after every MQINQMP is very bad from a performance standpoint, but I wasn't sure if calling an MQGET / MQINQMP pair in a loop is safe from a memory leak standpoint. Moreover, this program will work 24/7 in a separate JOB. – Victor Pomortseff Aug 19 '21 at 11:35
  • Glad it helped @VictorPomortseff. If the answer was helpful, StackOverflow etiquette is to accept the answer by clicking on the tick. – Morag Hughson Aug 20 '21 at 12:41
  • Morag, my reputaion is to low to cast a vote... "You need at least 15 reputation to cast a vote, but your feedback has been recorded." Unfortunately, the documentation from IBM leaves much to be desired in terms of the details of the operation of certain APIs. So your answer was quite helpful. – Victor Pomortseff Aug 21 '21 at 08:11
  • the person who posts the question is the one who accepts the answer. Accepting an answer is different from voting on the quality of the answer. – RockBoro Aug 21 '21 at 14:06
  • [To mark an answer as accepted, click on the check mark beside the answer to toggle it from greyed out to filled in.](https://stackoverflow.com/help/someone-answers) This is different than upvoting the question which is clicking the up arrow next to the answer. You only need 15 reputation to vote up so you can do both now as you have 31. – JoshMc Aug 21 '21 at 22:30
  • Looks like you figured it out @VictorPomortseff - welcome to Stackoverflow - I hope future questions you need to ask are also fruitful. It won't be long before you have the reputation needed to upvote things too, but "ticking" the answer is always appreciated. Cheers! – Morag Hughson Aug 22 '21 at 10:37