IBM MQ 5.3 for WIN Using Documents

xiaoxiao2021-03-06  105

MQ5.3 User Manual

Basic structure

Probably communication is:

The program of host A puts a message in the remote queue, the remote queue is looking for the corresponding transmission queue, the transfer queue finds the corresponding transmission channel, and the send channel places the message on the remote server (host B) with the same name of the transmit channel, The receiving channel is placed in the local acceptance queue of host B, and then the program of host B is responsible for taking the message.

2. This article demonstrates an unidirectional configuration process of communication logic from A to B.

The order is: a Establishing a Transport Queue --a Creating Send Channel --a Establishing Remote Queue -B Create Local Receive Channel-B Rating Local Accept Queue - Modify A Transmission Queue to join the self-starting function.

3. A Establish a transmission queue:

The transmission queue has enabled the role of the next layer 'Send Channel' and the upper "remote queue '. Open the' WebSphere MQ Explorer 'on the host A, as shown below

Enter a queue name in the queue name (this name is required to use the send channel in the future), IBM recommends the name of the queue and the queue manager on the top of B. The queue manager name on B is qm_kfb04, so you enter qm_kfb04 Due to need, I chose 'lasting' in 'default persistence', because the project data I develop cannot be lost. 'Usage' Be sure to select 'Transfer', indicating that this queue is a transfer queue.

The remaining settings are shown.

4. Create a send channel to B on A:

Enter a channel of a channel in the channel name, the name of its name must be the same as the name of the receiving channel on B, the reception channel name on B is' TOSF ', where the' TOSF ', the protocol selection TCP / IP,' connection name 'Is the IP address of B, the transfer queue selects the transfer queue we have established, to this' transmission queue QM_KFB04 'has been connected to the send channel' TOSF '. The rest is to establish a' transmission queue QM_KFB04 'Connected' Remote queue '. Enter a IP address of A in the 'local communication address'.

5. Create a remote queue QRB of B on A. Place the message in the queue when the program needs to be communicated with B, and the remote queue is established as shown below. In the 'Remote Queen Manager Name', enter B Queue Manager The name 'qm_kfb04', select the transmission queue established in 3 in the 'Transfer Queue Name' (to this: Channel-Transport Queue - Relationship between Remote Queuing). Enter B '' Local Queue in 'Remote Queue' Name 'Name LQB, B's upper program can take out messages from A directly in the LQB.

6. Establish a local receiving channel TOSF (the same name as required in 4)

7. Create a local acceptance queue LQB on B, the name of the 'remote queue name of 5 as required in 5. The program on the same. The program can take out the message from A by LQB.

8. Set the transfer team as self-start on A.

To this one of the network links created by system A to system B, it can establish two-way communication by the communication chain of B to A.

9. Communication Test

Open the 'first step by following the image below

Enter the following interface:

Select the API experimental program, the launcher is as follows:

Point MQCONN Connect A Local QM_SEA2K, after success, as shown above.

Then click the 'Queue' tab, select the remote queue QRB QRB, click the remote queue set in A, and enter a test message 'aaa' and then issue it.

Open the Web Sphere MQ Explorer on B. Select the local queue LQB on the B. You can see all the news from A.

10. The following is the C program code using MQ. The corresponding lib file and the H file in. C: / program files / ibm / websphere mq / tools / lib / mqm.lib C: / Program files / IBM / WebSphere MQ / Tools /C/include/cmqc.h, of course, there is also a written example of VB and Java, you can also find it. Below is the test code written by I wrote:

Key code sender in VC: a Open local queue manager qm_sea2k, then send an ILOVE message to the remote queue Qrb #include "testmq.h" #include "cmqc.h"

void CMainFrame :: OnSentMyMes () {MQHCONN Hcon; MQLONG CompCode; MQLONG Reason; char QMName [50]; strcpy (QMName, "QM_sea2k"); MQCONN (QMName, & Hcon, & CompCode, & Reason); if (CompCode == MQCC_FAILED) {MessageBox ( "fail"); return;} MQHOBJ Hobj; MQOD od = {MQOD_DEFAULT}; MQLONG O_options; strcpy (od.ObjectName, "QRB"); O_options = MQOO_OUTPUT MQOO_FAIL_IF_QUIESCING; MQOPEN (Hcon, & od, O_options, & Hobj , & CompCode, & Reason); if (Reason = MQRC_NONE) {MessageBox ( "open queqe fail"); return;}! MQMD md = {MQMD_DEFAULT}; / * Message Descriptor * / MQPMO pmo = {MQPMO_DEFAULT}; / * put message Options * / memcpy (md.format, / * character string format * / mqfmt_string, (size_t) mq_format_length); Memcpy (msgid, / * reset msgid to get a new one * / mqmi_none, sizeof (md.msgid)) ;

Memcpy (md.correlid, / * reset correlid to get a new one * / mqci_none, sizeof (md.correlid);

Char Buffer [100]; MQLONG Messlen; / * Message Length Received * / Messlen = 6; STRCPY (Buffer, "Ilove"); Memcpy (md.msgid, / * reset msgid to get a new one * / mqmi_none, Sizeof) md.msgid));

Memcpy (md.correlid, / * reset correlid to get a new one * / mqci_none, sizeof (md.correlid);

MQPUT (HCON, / * CONNECTION HANDLE * / HOBJ, / * Object Handle * / & MD, / * Message Descriptor * / & PMo, / * Default Options (Datagram) * / Messlen, / * Message Length * / Buffer, / * Message Buffer * / & compcode, / * complection code * / & it *; / * Reason code * // * Report Reason, if any * / if (Reason! = MQRC_NONE) {Printf ("MQPUT Ended with Reason Code% D / N" , REASON;}

MQLONG CO = MQCO_NONE; MQClose (HCON, & Hobj, Co, & Compcode, & Reason);

B Accept the message: Local QM_KFB04 Local QM_KFB04 Receive Message A Submission Ilove Void CMAINFRAME :: ONGETMYMES () {mqhconn hcon; mqlong compcode; mqlong reason; char qmname [50]; strcpy (Qmname , "QM_kfb04"); MQCONN (qMName, & Hcon, & CompCode, & Reason); if (CompCode == MQCC_FAILED) {MessageBox ( "fail"); return;} MQHOBJ Hobj; MQOD od = {MQOD_DEFAULT}; MQLONG O_options; strcpy ( od.ObjectName, "LQB"); O_options = MQOO_INPUT_AS_Q_DEF MQOO_FAIL_IF_QUIESCING; MQOPEN (Hcon, & od, O_options, & Hobj, & CompCode, & Reason); if (Reason = MQRC_NONE)! {MessageBox ( "open queqe fail"); return;}

MQMD md = {MQMD_DEFAULT}; / * Message Descriptor * / MQGMO gmo = {MQGMO_DEFAULT}; / * get message options * / md.Encoding = MQENC_NATIVE; md.CodedCharSetId = MQCCSI_Q_MGR; MQBYTE buffer [101]; / * message buffer * / MQLONG buflen; / * buffer length * / MQLONG messlen; / * message length received * / gmo.Options = MQGMO_WAIT / * wait for new messages * / MQGMO_CONVERT; / * convert if necessary * / gmo.WaitInterval = 15000; buflen = SIZEOF (Buffer) - 1; / * Buffer size available for get * / memcpy (md.msgid, mqmi_none, sizeof (md.msgid)); memcpy (md.correlid, mqci_none, sizeof (md.correlid); MD .Encoding = mqenc_native; md.codedcharsetid = mqccsi_q_mgr; MQGET (hpget (hp, / * connection handle * / hobj, / * Object handle * / & Md, / * Message Descriptor * / & gmo, / * get message options * / buflen, / * buffer length * / buffer, / * message buffer * / & message, / * message length * / & compcode, / * complection code * / & It); / * Reason code * /

/ * Report Reason, IF any * / if (Reason! = MQRC_NONE) {if (Reason == MQRC_NO_MSG_AVAILABLE) {/ * special report for normal end * / printf ("no more message / n");} else / * general report for other reasons * / {printf ( "MQGET ended with reason code% d / n", reason); / * treat truncated message as a failure for this sample * / if (reason == MQRC_TRUNCATED_MSG_FAILED) {CompCode = MQCC_FAILED;} }

/ ************************************************** ************** / / * DISPLAY EACH Message Received * / / ********************************* ************************************************* / IF (compcode! = Mqcc_failed) {buffer [ Messlen] = '/ 0'; / * add terminator * / printf ("Message <% s> / n", buffer;

Messagebox ((char *) buffer;}

Generally IBM MQ 5.3 has been able to work normally by these settings. After any one of the network is disconnected and at any one in A or B, the message sent by the other party will receive a message after communication. The rest of the knowledge I only Learn more, I don't dare to say guidance, I only hope that everyone can make progress together. Thank you

转载请注明原文地址:https://www.9cbs.com/read-96807.html

New Post(0)