Ibm websphere mq sample programs




















Sharing is caring. Happy Learning IBM MQ. April 11, April 11, ameadmin. It puts a sequence of messages to a queue with a two second delay between each message and displays events sent to its event handler.

No sync point is used to put messages to the queue. Reconnection can be made to any queue manager in the same queue manager group. To remove the example QueueManager and all associated objects, run the batch file exqmanremove. I have included a batch file "setpath" which will extend the path to include the directory where the csc. These may not be necessary depending on how your path variables are already set up.

I had a problem compiling as the compiler could not find the amqmdnet. I copied this DLL into the directory where the examples were running and all was well. To save any trouble, I have also copied this DLL into the zip file. You may not have this problem but at least you now know where the IBM. WMQ classes are. One deficiency I found was in exception handling. The MQException class returns the completion code and a reason code but there is no way to display the associated error text.

This meant that I had to look up the reason code in the Application Programmers Guide, page to find the message text and then page through the error messages which are in alphabetic order to get the explanation.

I decided to create a class MQRCText which has a static array containing all error message texts and one method getMQRCText which accepts the reason code and returns the message text. I made this into a DLL and all the example programs include this library in the compile statement. This saved me a lot of time as it was much easier to see my typos when I had a message about them rather than just a code which meant nothing to me.

I have built unique dynamic queue name using a text "dynam" concatenated with the user ID and time of day in the form hhmmssmmm. I could not get this feature to work.

Example 4 shows how to use the "Triggering" function of MQ. To start the monitor, run batch file runlexiq3. The example programs are already compiled and can be used as is. If you wish to change a program, just do the following to recompile:. If you get a message saying that it cannot find csc. Type in the message you want to PUT on the queue when requested.

The program writes to queue LEXQ1 and requests the next message. If you just hit return without typing anything in, then the program ends. The program reads from queue LEXQ1 and displays all the messages on the console, then the program ends. You could now use WebSphere MQ Explorer to browse the queue where you will see that the message has been read and the queue is empty. When a response message is received or the GET times out after 60 seconds , the program ends. The program reads from queue LEXQ1 and displays the message on the console, it then reads the ReplyToQueue and ReplyToQueueManager fields from the input message, uses these to fill the queue and queue manager names of the reply message and sends PUT s the reply message to the reply queue LEXQ2 , then the program ends.

Note: both programs will wait 60 seconds for a message before timing out. This can be changed in the source code by setting mqGetMsgOpts. The program writes to queue LEXQ1 and the program waits for a response on a dynamic queue which is created at run time.

When sending the request, the field ReplyToQueue contains the reply queue name dynamic and the field ReplyToQueueManager contains the reply queue manager name. The program reads from queue LEXQ1 and displays the message on the console, it then reads the ReplyToQueue and ReplyToQueueManager fields from the input message, uses these to fill the queue and queue manager names of the reply message and sends PUT s the reply message to the reply queue dynamic , then the program ends.

If then exmqrep2 is started, it will read the message on LEXQ1 but will NOT find the dynamic queue name to send back to as the dynamic queue is deleted when exmqreq2 is finished.

Run batch file runlexiq3. This will open its own DOS box in which you can see the trigger message which is sent when the example program runs. Type in the message you want to PUT on the queue when requested to do so. The program writes to queue LEXAQ3 and the program waits for a response on a dynamic queue which is created at run time. This trigger message is read from the Initiation queue by the Monitor program which was previously started by batch file runlexiq3.

The program reads from queue LEXAQ1 and displays the message on the console, it then reads the ReplyToQueue and ReplyToQueueManager fields from the input message, uses these to fill the queue and queue manager names of the reply message and sends PUT s the reply message to the reply queue dynamic , then the program ends. I hope these examples help you to get going with C and MQSeries. I will be writing a follow up to this, describing the usage of transmission queues and triggering CICS transactions from C.

If you have any questions, corrections, comments etc. This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. IBM MQ is robust messaging middleware that simplifies and accelerates the integration of diverse applications and business data across multiple platforms.

IBM MQ facilitates the assured, secure and reliable exchange of information between applications, systems, services, and files by sending and receiving message In addition to examples provided by pymqi, see also our Python samples in this GitHub repo.

This example uses a local MQ instance running in a Docker container. You perfo…. Home Extension Country Picing. Keyword Research: People who searched ibm mq example also searched.

Frequently Asked Questions.



0コメント

  • 1000 / 1000