Upload
buithien
View
231
Download
0
Embed Size (px)
Citation preview
Michigan iSeries Technical
Education Conference
MQ Series
IBMs Middleware
SolutionPresented by
Ryan Technology Resources
Michael Ryan
(C)opyright 2006(C)opyright 2006(C)opyright 2006
Michael RyanMichael RyanMichael Ryan
What is Middleware?
Middleware is software that
manages several parts of a
connection between systems
Physical and logical communications
Data translation
Error recovery
Message sequencing
MQ Series
Proper name is Websphere MQ
Framework for communications
Multiple levels
Different operating systems
Different hardware platforms
Different communication protocols
Ubiquitous connectivity
Multiple Platforms
AIX
Compaq NSK
DOS
DYNIX/ptx
HP-UX
Linux
MacOS MVS/ESA
NUMA-Q
OpenVMS Alpha
OpenVMS VAX
OS/2
OS/390
OS/400
Sun Solaris
UNIX
Unisys 2200 Series
Unisys A Series
VM/ESA
VSE/ESA
Windows Java
Access
Programmatically accessed through Application Programming Interfaces (API)
Same concept for each system
Store and Forward
Not unlike SNADS
Guaranteed delivery
Asynchronous communication
Components
Four main components of MQ Series
Queue manager
Queues
Channels
Messages
Messages
The data being sent between applications Has meaning to the application no particular
meaning to MQ Series
Two parts the application data and a message descriptor Application data is what the applications are sending
and receiving with each other
Message descriptor is something that is not seen by the application programmer. It contains information such as the from and to queue names, the priority, levels of MQ Series, security information and so on
Queues
Message repository - sent to or received from
Not unlike data queues (*DTAQ) Use APIs to access MQ Series data queues
Independent of the application
Characteristics Put-enabled (messages can be placed on the queue)
Get enabled (messages may be retrieved from the queue)
Queue depth
Queue size
Queue Manager
Responsible for queues
Every queue belongs to a queue manager, whether the queue is local or remote A local queue managed by a local queue manager
a queue manager on the same system as a queue
A remote queue is manager by a remote queue manager a queue manager on a different system
A local application puts messages on a remote queue (which is a local queue to the remote system) and the remote application puts messages on a local queue (which is remote to the local application)
Queue Manager
Local System Remote System
Remote Queue Local Queue
Local QueueRemote Queue
Managed by
remote system
queue manager
Managed by
local system
queue manager
Channels
Link between the actual communications and
the MQ Series queue managers
Type of communications (TCP/IP or SNA)
Two types message channels and client channels
A message channel is used for server-to-server communication
Unidirectional
Two channels - a sending channel and a receiving channel
A client channel connects a client to a server
Bi-directional
Queues exist on the server there are no client queues
MQ Configuration
Use RSTLICPGM 5733-A38
Developed in Hurlsley, supported from Raleigh (Software Group)
Loads QMQM library
Objects in the IFS
User profiles QMQM and QMQMADM
Read the instructions
MQ Configuration - WRKMQM
MQ Configuration - CRTMQM
MQ Configuration -CRTMQMCHL
MQ Configuration -CRTMQMQ
MQ Programming
The programming model for MQ Series
applications is similar to any communications
program
One system (usually the client) sends a message (a
request for services) to the other system (usually the
server)
The server then replies with the information desired
by the client. This process continues until the client or the server desire to end the communication.
MQ Programming
Contrast MQ Series with sockets programming
Amount of code needed for an MQ Series
program is much less than a socket program
Dont need to code for low-level handshaking
Low-level error recovery is performed by MQ
Dont need to connect or accept
Just read and write to queues
MQ Programming - APIs
Application Programming Interface Relatively few APIs
Most commonly used
MQCONN Connect to a Queue Manager
MQDISC Disconnect from a Queue Manager
MQOPEN Open an MQ object (Queue)
MQCLOSE Close an MQ object (Queue)
MQPUT Put a message to an MQ Queue
MQGET Get a message from an MQ Queue
MQ Programming - APIs
Other APIs are available but usually not needed
MQINQ Inquire about an MQ object (Queue,
Queue Manager, Channel)
MQSET Set some of the attributes of a Queue
MQBEGIN Begin a Unit of Work in a Commitment Control environment
MQCMIT Commit a Unit of Work in a Commitment Control environment
MQBACK - Rollback a Unit of Work in a Commitment Control environment
MQ Programming - Model
The general flow of events in an MQ Series application program is:
1.Connect to a queue manager with MQCONN
2.Open the queues needed for communication with MQOPEN
3.Use MQPUT and MQGET to send and receive messages
4.Close the opened queues with MQCLOSE
5.Disconnect from the queue manager with MQDISC
MQ Programming - RPG
MQ Series applications usually follow the model
Using MQ Series in an RPG application is
simple
Procedures called by the APIs are in service
program QMQM/LIBMQM
Ensure this service program is bound by reference
with your RPG program
The data structures and prototype definitions
can be found in library QMQM
MQ Programming - RPG
Heres an example of /INCLUDEs I use in my MQ Series programs:
* MQI Named Constants
/COPY QMQM/QRPGLESRC,CMQG
* Object Descriptor
D MQOD DS
/COPY QMQM/QRPGLESRC,CMQODG
* Message Descriptor
D MQMD DS
/COPY QMQM/QRPGLESRC,CMQMDG
* Get Message Options
D D D D MQGMO DS/COPY QMQM/QRPGLESRC,CMQGMOG
* Put message options
D MQPMO DS
/COPY QMQM/QRPGLESRC,CMQPMOG
MQ Programming - RPG
These includes will copy in
Named constants
Object descriptor information
Message descriptor information
Put and get option information
Review these include files to identify the field names and prototyped names you will use in your program
MQ Programming - RPG
Example of connecting to a queue manager:
* Connect to MQ Series queue manager.
C CallP MQConn(QMName :
C HConn :
C OCode :
C Reason)
C If OCode = CCFail
* Error occurred...
C EndIf
MQ Programming - RPG
QMName contains the name of the queue manager
HConn is returned from the API call Contains the handle that will be used in later calls
The handle identifies the specific queue manager and is used internally by MQ Series
OCode and Reason are returned by the API call and identify if an error occurred Note: I check OCode to see if it is equal to the named constant
CCFail if so, an error occurred
Appropriate error recovery code goes here
This call completes the first step in the MQ Series application flow connecting to the queue manager
MQ Programming - RPG
Example of opening a queue:* Options are input-as-queue-def and fail-if-quiescing
C Eval Opts = OOInpq + OOFIQ
C Eval ODon = ReplyQue
C CallP MQOpen(HConn :
C MQOD :
C Opts :
C HInObj :
C OCode :
C Reason)
C If Reason RCNone
* Error occurred...
C EndIf
MQ Programming - RPG
Variable Opts is set to special named constant values OOInpq and OOFIQ Open the queue as input
Fail if quiescing
Variable ODon has the value of ReplyQue Contains the name of a queue
Association already established between the queue manager and the queue during creation
HConn is the queue manager handle Obtained from the MQConn call
MQ Programming - RPG
MQOD variable specified in the MQOpen call is a data structure. ODon is one of the many subfields in the data
structure
HinObj is returned from the API call and contains the handle for the opened queue Used for puts and gets
OCode and Reason a