IBM WebSphere MQ programming consists of two parts: MQ system management programming and MQ application development programming.
/* Reprinted Please retain copyright: Author: Lei Lin QQ: 64607646E-mail: ralinlei@gmail.com*/
IBM WebSphere MQ programming consists of two parts: MQ system management programming and MQ application development programming.
MQSystem Management Programming:
The so-called MQ system management programming refers to using the programming interface provided by MQ to compile specific applications for monitoring and managing various MQ objects, such: query the running status of the channel and queue depth, query the queue manager attributes, queue attributes, channel attributes, and other static parameters, and perform various MQ operations, such: start/stop channels, create/delete various objects, and modify attributes of various objects.
In fact, MQ provides us with a variety of system management methods, including:
- Use the MQ graphical management interface for operations, monitoring, and management: MQ resource manager provides a good management interface for users to conveniently configure and manage the middleware system, with MQ resource manager, you can define, modify, and delete various resources and objects of middleware, view attributes of various objects, and monitor the running status of various objects;
- Mqsc commands are used to operate, monitor, and manage MQ through command lines. In particular, mqsc commands are the same on various platforms, in a system where multiple platforms coexist, system management is greatly facilitated and simplified.
- Through specific system management tools for monitoring and management, MQ not only provides GUI and regionalization monitoring tools to monitor and display the object status, it can also use various system management software to monitor the running status of the entire network. For example, Tivoli manager for MQ is a powerful integrated management tool: it provides a centralized management platform for controlling messages and application frameworks. It captures and displays MQ events and discovers new queue managers and corresponding objects. These objects can be defined and configured on the central console. In addition, many third-party manufacturers provide similar management tools.
In addition to the above three management methods, MQ also provides a system management programming interface through which users can write applications for automated real-time monitoring and management. There are two types of MQ system management interfaces: programmable Command Format (Programmable command format, PCF for short) and MQ administration interface (MQ Management Interface, mqai for short ).
MQApplication Development Programming:
MQ application development programming mainly refers to the use of mqi, Ami, ActiveX programming interfaces for message sending and receiving and related application development.
MqiThat is, Message Queue Interface:
It provides basic and rich programming interfaces, and also provides the most comprehensive operation group .. It is widely used and supports most platforms and programming languages.
For example, the operating system supports AS/400, SunOS, Aix, and Windows. The programming languages include C, C ++, VB, PL/I, COBOL, RPG, and Delphi.
Mqi can be used to process:
- Connect and disconnect a queue manager
- Open and Close a queue object
- Send, browse, and receive messages
- Query and set Object Attributes
- Transaction Management
- Message Group
AmiThat is, application message interface:
It provides a simple interface for programmers to process Queue Manager objects. With the AMI, programmers do not have to have a deep understanding of all mqi calls. They only need to focus on the business logic of the application. This means fewer errors occur during programming and higher flexibility to handle business and technological changes. Ami reduces the amount of code required to write new applications.
The following methods can be used to send and receive message Ami:
- Send-forgotten, no reply required
- Allocate table to send messages to multiple destinations
- Request/reply: The application sending the message needs to request a reply to the message.
- Publish/subscribe, managed by the agent for message distribution
Due to the small amount of information on MQ development on the Internet, some people need to use MQ for development in a recent project. Due to the lack of knowledge about multi-MQ programming, therefore, we do not know how Delphi and MQ are associated.
In the MQ programming mode, currently, only mqi supports Delphi development in the materials I have verified. In addition, there are many third-party components in Delphi, A company in the United States provides a Delphi for MQ component, which is very simple to use. Unfortunately, this component is charged.
Delphi uses the mqi interface, and provides official documentation guidance.
Http://www-1.ibm.com/support/docview.wss uid = swg24007060, the document describes the Delphi mqi API interface and C similar, the official programming mqi programming guide for Delphi is also very suitable. The pointer is used in the C language and another way to define the string length is to mark the end with #0; in Pascal, @ operator is used to pass pointer values.
The most common mqi programming is the call of 13 common functions:
Mqconn
Mqconnx
Mqdisc
Mqopen
Mqclose
Mqput1
Mqput
Mqget
Mqinq
Mqset
Mqbegin
Mqcmit
Mqback
1 mqconn Demo
An instance is displayed today to demonstrate the successful connection to the queue manager and learn some related concepts.
System Environment:Win2000 Pro + SP4, mq5.3, Delphi7
You must create a form, a memo, and a button in Delphi.
Procedure tform1.btncoonclick (Sender: tobject );
VaR
Hconn: mqhconn; // connection handle
Compcode, reason: mqlong; // code to complete, cause code
Qmgrname: string; // Queue Manager name. The custom type variable of MQ is not used here.
Begin
Qmgrname: = 'dmq ';//
Mqconn (pchar (qmgrname ),
// Pchar is equivalent to char * in C and ends with #0, but you do not need to allocate memory for it during use.
Hconn,
Compcode,
Reason );
{Compcode has four statuses: mqcc_ OK = 0;
Mqcc_warning = 1;
Mqcc_failed = 2;
Mqcc_unknown =-1 ;}
If compcode = mqcc_failed then
Begin
Memo1.lines. Add ('Connection failed ');
Memo1.lines. Add ('the name of the connected queue manager is '+ qmgrname );
Memo1.lines. Add (inttostr (reason ));
End;
If compcode = mqcc_warning then
Begin
Memo1.lines. Add ('Warning ');
End;
If compcode = mqcc_ OK then
Memo1.lines. Add ('Connection successful ');
End;