Introduction to z/OS Basics © 2006 IBM Corporation Chapter 15: WebSphere MQ
Dec 21, 2015
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
2
Chapter objectives
Be able to:
Explain why messaging and queuing is used
Describe the asynchronous flow of messages
Explain the function of a queue manager
List three zSeries-related adapters
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
3
Key terms in this chapter
local queue
channel
message-driven
MQI
asynchronous application
dead-letter queue
QM
remote queue
syncpoint
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
4
What is MQ?
Most large organizations today have IT systems from various manufacturers.... makes it difficult to share communications and data across systems.
These organizations need to communicate and share data with suppliers and customers, who might also have disparate systems.
Handy to have a messaging tool that could receive data from one type of system and send that data to another type.
WebSphere MQ facilitates application integration by passing messages between applications and web services.
It is used on more than 35 platforms. . In the largest installation, billions of messages a day are transmitted.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
5
What is MQ?
Message queues, and the software that manages them enable program-to-program communication.
Messaging and Queuing an be understood as follows:
Messaging means that programs communicate by sending each other messages (data) rather than by calling each other.
Queuing means messages are placed on queues in storage,
Programs can run independently of each other, at different speeds and times,in different locations, and without having a logical connection between them.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
6
Synchronous communication model
BB
AA
MQI
MQI
MQI
MQI
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
7
Synchronous Communication
Program A prepares a message and puts it on Queue 1.
Program B gets the message from Queue 1 and processes it.
Both Program A and Program B use an application programming interface (API) to put messages on a queue and get messages from a queue.
The MQ API is called the Message Queue Interface (MQI).
When Program A puts a message on Queue 1, Program B might not be running. The queue stores the message safely until Program B starts and is ready to get the message.
When Program B gets the message from Queue1, Program A might no longer be running. For this model, there is no requirement for two programs communicating with each other to be executing at the same time.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
8
Asynchronous communication model
BB
CC
AA
MQI
MQI
MQI
MQI
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
9
Asynchronous Communication
Using the asynchronous model, Program A puts messages on Queue 1 for Program B to process
Program B sends the responses to Queue 2
It is Program C, acting asynchronously to Program A, gets the replies from Queue 2 and processes them.
Typically, Program A and Program C would be part of the same application.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
10
Three Styles of Communication
ProgramA
ProgramB
ProgramC
ProgramA
Conversational
Messaging
Call and return
ProgramA
ProgramB
ProgramA
ProgramA
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
11
Message Types for MQ
Types of messages
Datagram: message for which no response is expected.
Request: A message for which a reply is requested.
Reply: A reply to a request message.
Report: A message that describes an event, such as the occurrence of an error or a confirmation of the arrival of a delivery.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
12
Queue Manager
Messages
Program
Data
Program
Program
Queuemanager
DB2
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
13
Queue Manager (QM)
The QM owns and manages queues
It provides services for applications, ensures that messages are: -put in the correct queue, -routes messages to other queue managers, and - processes messages through a common programming interface (MQI).When an application puts a message on a queue, the queue manager ensures that the message is: Stored safely Recoverable Delivered once, and once only, to the receiving applicationThis is true even if a message has to be delivered to a queue owned by anotherqueue manager; this situation is known as the assured delivery property ofWebSphere MQ.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
14
Queue Manager (QM)
The QM owns and manages queues
It provides services for applications, ensures that messages are:
-put in the correct queue,
-routes messages to other queue managers, and
- processes messages through a common
programming interface (MQI).
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
15
Queue Manager (QM)
When an application puts a message on a queue, the queue manager ensures that the message is:
-Stored safely
-Recoverable
-Delivered once, and once only, to the receiving application
This is true even if a message has to be delivered to a queue owned by another queue manager; this situation is known as the assured delivery property
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
16
Message Queue Interface (MQI)
Application
Queue manager
MQI
Queue manager
object
Namelist object
Process object
Major callsMQCONNMQCONNXMQOPENMQCLOSEMQPUTMQPUT1MQGET
Minor callsMQBEGINMQCMITMQBACKMQINQMQSET
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
17
Message layout
Set by application and queue managerHeaders
MQMDMQXQHMQDLHand so forth
Any sequence of bytesPrivate to the sending and receiving applicationsNot meaningful to the queue manager
Message = Headers + Application data
ApplicationHeaders
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
18
Queue types
Program A Program B Program C
System 1 System 2
MQPUT Q2 MQPUT Q1 MQGET Q1 MQGET Q2
Queuemanager
Queuemanager
MQI
QX Q1 Q2DLQ
Network - MCA
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
19
Queue types
Local queue- is owned by the QM to which the application program is connected. It stores messages for programs that use the same QM. The application program does not have to run on the same machine as the queue manager. Remote queue - Owned by a different QM. A remote queue is not a real queue; it is only the definition of a remote queue to the local QM. Programs cannot read messages from remote queues. Remote queues are associated with a transmission queue.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
20
Queue types
Transmission queue - This local queue has a special purpose: it is used as an intermediate step when sending messages to queues that are owned by a different QM. Transmission queues are transparent to the application.They are used internally by the queue manager channel initiator.
Initiation queue - A local queue to which the QM writes (transparently to the programmer) a trigger message when certain conditions are met on another local queue, for example, when a message is put into an empty message queue or in a transmission queue.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
21
Channels
MQI
Program 1
putget
QMA
Local Q2
ChannelQMB.QMAReceiver
Remote Q1
XmitQQMB
ChannelQMA.QMBSender
MQI
Program 2
putget
QMB
Local Q1
ChannelQMB.QMBReceiver
Remote Q2
XmitQQMA
ChannelQMB.QMASender
Network
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
22
Channels
A Channel is a logical communication link. The conversational style of program-to-program communication requires the a communications connection between each pair of applications. Channels shield applications from the underlying communications protocols.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
23
Channels TypesA Message Channel connects two queue managers through message channel agents (MCAs). A message channel is unidirectional, composed ofa sender and a receiver agent and a communication protocol. An MCA transfers messages from a transmission queue to a communication link, and from a communication link to a target queue. Bidirectional communication requires 2 channels.
An MQI channel connects an MQ client to a queue manager. Clients do not have a queue manager of their own. An MQI channel is bidirectional.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
24
Security
Local Queue Manager
Remote Queue Manager
MCAMCA
MCAMCA
MQMDApplication
Data
USERID
Context
Database
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
25
Data Integrity
DBDBWriteSend
Syncpoint
ReceiveWrite DBDB
Syncpoint2-phasa
commit
Synchronousmodel
Unit of work
DBDB Write
PutSyncpointUnit of work 1
Unit of work 2
Unit of work 3
qq Get
WriteSyncpoint
DBDB
Asynchronousmodel
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
26
Data Integrity(1)
The top half shows a two-phase commit structure, while the MQ solution is shown in the lower half, as follows:
>The first application writes to a database, places a message on a queue, and issues a sync point to commit the changes to both resources.
>The message contains data that is to be used to update a second database on a separate system. Because the queue is a remote queue, the message goes to the transmission queue within this unit of work.
>When the unit of work is committed, the message becomes available for retrieval by the sending MCA.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
27
Data Integrity(2)
>In the second unit of work, the sending MCA gets the message from the transmission queue and sends it to the receiving MCA on the other system ,
>The receiving MCA places the message on the destination queue. This is reliable because of the assured delivery property of MQ.
>When committed, the message becomes available for retrieval by the second application.
>In the third unit of work, the second application gets the message from the destination queue and updates the database using the data contained in the message.
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
28
Travel agency example revisited
MQPUT CAR RENTAL
MQPUT FLIGHT
MQPUT HOTEL
MQGET Reply-to-queue
Car rental
Flight
Hotel
Car
Flight
Hotel
MQPUT
MQPUT
MQPUT
Reply-to queue
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
29
Interfacing to WebSphere MQ
MQ is available on many platforms
On z/OS it has interfacing to:
– CICS
– IMS
– Batch or TSO
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
30
MQ functions
Common application programming interface (MQI)
Assured delivery: messages do not get lost and they arrive only once
No synchronous access needed
Message driven application
Quicker development due to shielding of the network
Chapter 15 WebSphere MQ
© 2006 IBM Corporation
31
Summary
Messaging and queuing enables communication between applications on different platforms.
WebSphere MQ is an example of software that manages messaging and queuing in the mainframe and other environments.
With messaging, programs communicate by through messages, rather than by calling each other directly.
With queuing, messages are retained on queues in storage, so that programs can run independently of each other (asynchronously).