page 8 MQSeries Part 2 The Remote Queue Manager

04/08/00 MQ Series Middleware Presentation
John Tullis
DePaul Instructor
[email protected]
Copyrighted material
John Tullis
7/29/2017
page 1
MQSeries Part 2
The 3 basic concepts
• Messages - covered last week
• Queues
• Queue Managers
Copyrighted material
John Tullis
7/29/2017
page 2
MQSeries Part 2
The Queue Manager
• Owns and creates Q objects
•Create default QMgr X
• crtmqm /q X
•Start QMgr X
• strmqm X
•End QMgr X (immediate)
• endmqm /i X
•Delete QMgr X
• dltmqm X
Copyrighted material
John Tullis
7/29/2017
page 3
MQSeries Part 2
Queues
• A queue is a data structure in which messages are stored.
The messages may be put on, or got from, the queue by
applications or by a queue manager as part of its normal
operation.
• Queues exist independently of the applications that use them.
A queue can exist in main storage (if it is temporary), on disk
or similar auxiliary storage (if it must be kept in case of
recovery), or in both places (if it is currently being used, and
must also be kept for recovery). Each queue belongs to a
queue manager, which is responsible for maintaining it. The
queue manager puts the messages it receives onto the
appropriate queue.
Copyrighted material
John Tullis
7/29/2017
page 4
MQSeries Part 2
Queue attributes determine...
• Whether applications can retrieve messages from the queue
(get enabled)
• Whether applications can put messages onto the queue (put
enabled)
• Whether access to the queue is exclusive to one application
or shared between applications
• The maximum number of messages that can be stored on the
queue at the same time (maximum queue depth)
• The maximum size of messages that can be put on the queue
(maximum message size)
Copyrighted material
John Tullis
7/29/2017
page 5
MQSeries Part 2
The Queue Manager
• A queue manager provides queuing services to applications,
and manages the queues that belong to it. It ensures that:
• Object attributes are changed according to the details
received.
• Special events (such as instrumentation events or
triggering) are generated when the appropriate
conditions are met.
• Messages are put on the correct queue, as requested by
the application. The application is informed if this
cannot be done, and an appropriate reason code is given.
Copyrighted material
John Tullis
7/29/2017
page 6
MQSeries Part 2
The Local Queue Manager
• Each queue belongs to a single queue manager and is said to be a
local queue to that queue manager.
• The queue manager to which an application is connected is said to
be the local queue manager for that application.
• For the application, the queues that belong to its local queue
manager are local queues.
Copyrighted material
John Tullis
7/29/2017
page 7
MQSeries Part 2
The Remote Queue Manager
• A remote queue is a queue that belongs to another queue manager.
• A remote queue manager is any queue manager other than the
local queue manager.
• A remote queue manager may exist on a remote machine across
the network or it may exist on the same machine as the local queue
manager.
• MQSeries supports multiple queue managers on the same
machine.
Copyrighted material
John Tullis
7/29/2017
page 8
MQSeries Part 2
Message Channels
• Communication by applications with queues managed by another
queue manager requires message channels to be defined. It is not
necessary to define a channel directly to the target queue manager
and it is often appropriate to define one only to the next hop (that
is, an intermediate queue manager). Message channels available
from that queue manager will be used to deliver the message to the
target queue manager (or even to a subsequent hop).
Copyrighted material
John Tullis
7/29/2017
page 9
MQSeries Part 2
Message Channels
• A message channel provides a communication path between two
queue managers on the same, or different, platforms. The message
channel is used for transmitting messages from one queue manager
to another, and shields the application programs from the
complexities of the underlying networking protocols. A message
channel can transmit messages in one direction only. Two message
channels are required if two-way communication is required
between two queue managers.
Copyrighted material
John Tullis
7/29/2017
page 10
MQSeries Part 2
Message Channels
• Channels are used to send messages from one Queue
Manager to another Queue Manager
•Channels send messages in one direction only
•A Channel consists of two message channel agents (MCA):
a sending MCA and a receiving MCA
Q
u
e
u
e
M
a
n
a
g
e
r
Q
u
e
u
e
M
a
n
a
g
e
r
XC
h
a
n
n
e
l
s Y
1
Q
m
e
r
1
Q
R
S
D
R
R
C
V
R
X
.
Y
A
1
Q
B
1
Q
R
m
e
r
R
C
V
R
S
D
R
Y
.
X
Copyrighted material
John Tullis
7/29/2017
page 11
MQSeries Part 2
Message Channels
• Queue managers X and Y can be on the same machine.
Q
u
e
u
e
M
a
n
a
g
e
r
X
Q
u
e
u
e
M
a
n
a
g
e
r
Y
C
h
a
n
n
e
l
X
.
Y
1
Q
1
Q
m
e
r
A
h
a
n
n
e
l
Y
.
X
1C
Q
R
1
Q
R
m
e
r
Copyrighted material
John Tullis
7/29/2017
page 12
B
MQSeries Part 2
Message Channels
• Queue managers X and Y can be on different machines.
Q
u
e
u
e
M
a
n
a
g
e
r
X
Q
u
e
u
e
M
a
n
a
g
e
r
Y
C
h
a
n
n
e
l
X
.
Y
1
Q
1
Q
m
e
r
A
h
a
n
n
e
l
Y
.
X
1C
Q
R
1
Q
R
m
e
r
Copyrighted material
John Tullis
7/29/2017
page 13
B
MQSeries Part 2
Local & Remote Q’s
•Local Q: queue physically exists on local system (e.g., Q1)
•Remote Q: pointer to queue on another system (e.g., remQ1)
•Transmit Q: special local queue which holds message until the
message channel can send message to remote system. (xmitq)
Q
M
g
r
X
Q
M
g
r
Y
1
Q
1
Q
m
e
r
B
X
.
Y
Q
t
i
m
x
.
Y
A
Copyrighted material
John Tullis
7/29/2017
page 14
MQSeries Part 2
Transmitting a message to a remote Queue
Q
M
g
r
X
Q
M
g
r
Y
4
1
Q
1
Q
m
e
r
B
X
.
Y
3
1
Q
t
i
m
x
.
Y
2
A
Copyrighted material
John Tullis
7/29/2017
page 15
MQSeries Part 2
Transmitting a message to a remote Queue
• (1)Application A puts message to a remote queue (remQ1)
(application program does not need to know if target queue is local or
remote)
• (2)MQ automatically attaches transmit header to message and places
message on transmit q (Y.xmitQ)
• (3) MQ sender channel agent sends message to receiver channel
agent, which then places message on local queue of target QMgr (Q1)
• (4)Application B gets message from local queue (Q1)
Copyrighted material
John Tullis
7/29/2017
page 16
MQSeries Part 2
Round Robin
• (1) Application A puts message to a remote queue (remQ1)
• (2) MQ automatically places message on transmit q (Y.xmitQ)
• (3) MQ sender channel agent sends message to other system, which
then places message on local queue of target QMgr (Q1)
• (4) Application B gets message from local queue (Q1)
• (5) Application B puts reply message to a remote queue (remRQ1)
• (6) MQ automatically places message on transmit q (X.xmitQ)
• (7) MQ channel sends message to target system and places
message on local queue of target QMgr (RQ1)
• (8) Application A gets message from local queue (RQ1) QMgr
Copyrighted material
John Tullis
7/29/2017
page 17
MQSeries Part 2
Round Robin
Q
M
g
r
X
Q
M
g
r
Y
1
Q
1
Q
m
e
r
B
X
.
Y
Q
t
i
m
x
.
Y
Y
.
X
A
1
Q
R
Copyrighted material
John Tullis
7/29/2017
Q
t
i
m
x
.
X
1
Q
R
m
e
r
page 18
MQSeries Part 2
Different Queue Types
• Local Queues
• Owned by Queue Manager application connected to
• Applications can put and get messages
• Transmission, Dead-Letter, System Command, Event, etc
•Remote Queue
• Owned by different Queue Manager
• Applications can only put message
•Alias Queues
• used to access another queue
Copyrighted material
John Tullis
7/29/2017
page 19
MQSeries Part 2
Alias Queues
• allows applications to access a queue by referring to it indirectly in
MQI calls
•Name is resolved to local or remote queue at run time (many to one)
•Allows the queues that an application uses to be changed without
changing the application in any way
• merely change the alias queue definition
•Access authorization (read/write) can be established using alias
queues
• one alias queue has read only,
• another alias to same physical queue has write access
Copyrighted material
John Tullis
7/29/2017
page 20
MQSeries Part 2
Processes and Triggering
• An application program or a message channel can be started /
triggered when a message arrives on a queue
•A MQ process is the definition of that program or channel to MQ
•A queue definition references the MQ process and is used to indicate
that triggering is enabled
Copyrighted material
John Tullis
7/29/2017
page 21
MQSeries Part 2
Administrative Commands
• You use the MQSeries (MQSC) commands to manage queue
manager objects, including the queue manager itself, channels,
queues, and process definitions. For example, there are commands to
define, alter, display, and delete a specified queue. To execute these
commands you must invoke the control command:
• runmqsc
• You can use file indirection / redirection:
• runmqsc < filename.in > filename.out
• To run to create system / default objects:
• runmqsc < amqscoma.txt
Copyrighted material
John Tullis
7/29/2017
page 22
MQSeries Part 2
Application Programming
A
p
p
l
i
c
a
t
i
o
n
P
r
o
g
r
a
m
"majorcls"
t
y
p
i
c
a
l
l
y
C
o
r
C
o
b
o
l
a
l
s
o
J
a
v
a
&
L
o
t
u
s
S
c
r
i
p
t
M
Q
C
O
N
N
.
.
.
.
.
.
.
.
.
.
.
.
.
c
o
n
n
e
c
t
s
a
p
p
l
i
c
a
t
i
o
n
t
o
s
p
e
c
i
f
i
c
q
u
e
u
e
m
a
n
a
g
e
r
M
Q
O
P
E
N
.
.
.
.
.
.
.
.
.
.
.
.
.
o
p
e
n
s
a
p
a
r
t
i
c
u
l
a
r
q
u
e
u
e
f
o
r
i
n
p
u
t
/
o
u
t
p
u
t
/
b
o
t
h
M
Q
P
U
T
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
p
u
t
s
a
m
e
s
s
a
g
e
o
n
t
o
a
m
e
s
s
a
g
e
q
u
e
u
e
w
i
t
h
o
p
t
i
o
n
s
M
Q
G
E
T
.
.
.
.
.
.
.
.
.
.
.
.
.
.
g
e
t
s
a
m
e
s
s
a
g
e
f
r
o
m
a
m
e
s
s
a
g
e
q
u
e
u
e
w
i
t
h
o
p
t
i
o
n
s
M
Q
C
L
O
S
E
.
.
.
.
.
.
.
.
.
.
.
.
c
l
o
s
e
s
a
q
u
e
u
e
M
Q
D
I
S
C
.
.
.
.
.
.
.
.
.
.
.
.
.
.
d
i
s
c
o
n
n
e
c
t
s
a
p
p
l
i
c
a
t
i
o
n
f
r
o
m
q
u
e
u
e
m
a
n
a
g
e
r
Copyrighted material
John Tullis
7/29/2017
page 23
MQSeries Part 2
Application Programming
•MQPUT1 - implements open, put 1 message, close of queue
•MQCMIT / MQRLBK - commits/rolls back get/put of messages
under sync. control
•MQINQ / MQSET - inquiry/set of MQ object options
Copyrighted material
John Tullis
7/29/2017
page 24
MQSeries Part 2
Transactional support
• An application program may need to group a set of updates into a
unit of work. Such updates are usually logically related and must all
be successful for data integrity to be preserved. Data integrity would
be lost if one update in the group succeeded while another failed.
MQSeries supports transactional messaging.
• A unit of work commits when it completes successfully. At this
point all updates made within that unit of work are made permanent
and irreversible. Alternatively, all updates are backed out if the unit
of work fails. Syncpoint coordination is the process by which a unit
of work is either committed or backed out with integrity.
Copyrighted material
John Tullis
7/29/2017
page 25