Page 1 of 1

difference b/w MQ put and Get

Posted: Wed Dec 09, 2015 12:55 pm
by Dhiraj
Hello All,

I Need your suggestion and help in below MQ process.

In coding when we are Putting the data we are calling MQPUT1(after MQCONN) without opening the MQ

but when we are getting data from MQ then we are opening the MQ...

so during MQPUT1, it already opens the MQ?? but do we need to Open MQ for getting the data from there??

Just add: during MQPUT1 we are giving the MQ name what we are using.


Thanks,
Dhiraj.

Re: difference b/w MQ put and Get

Posted: Wed Dec 09, 2015 2:39 pm
by Anuj Dhawan
Hi Dhiraj,

The question in your subject line differs from what you've in the content of the thread.Are you really asking about the difference between MQPUT and MQGET calls or the difference between MQPUT and MQPUT1 calls?

I'll assume it's for the later part and if so, read on:

MQPUT1 is useful for putting a single message to a destination. And it is essentially equivalent to issuing MQOPEN, MQPUT, MQCLOSE. Since MQPUT1is a single MQI call it is more efficient. As such it is often used by server applications which need to send a single reply to requesting applications.

If you need to send more than one message then you are better off issuing the MQOPEN, MQPUT{*}, MQCLOSE sequence.

If you want to study further, you can see the difference here at MQPUT – Put message and MQPUT1 – Put one message. Which states:
MQPUT – Put message
The MQPUT call puts a message on a queue or distribution list, or to a topic. The queue, distribution list or topic must already be open

MQPUT1 – Put one message
The MQPUT1 call puts one message on a queue, or distribution list, or to a topic. The queue, distribution list, or topic does not need to be open

Re: difference b/w MQ put and Get

Posted: Wed Dec 09, 2015 3:34 pm
by Dhiraj
Thanks Anuj for this information. yes I was not clear about heading of this question. :)

so for MQPUT1 we don't need to call MQOPEN but for MQGET we need to Open the MQ(MQOPEN)?

Re: difference b/w MQ put and Get

Posted: Wed Dec 09, 2015 4:42 pm
by Anuj Dhawan
MQPUT1 actually does an MQOPEN, MQPUT, and MQCLOSE, so you as a programmer don't type it. By definition, MQGET is the function which gets a message from a local queue that was opened for input by using the MQOPEN function - so yes you need to "open the queue".