45

As400 Training Mq Series

Embed Size (px)

Citation preview

Page 1: As400 Training Mq Series
Page 2: As400 Training Mq Series

Table of Contents What is MQSeries

MQSeries Terminology

MQSeries Facilities

MQSeries Features and Functionality

MQSeries Components and its uses

MQSeries Application Programming

Page 3: As400 Training Mq Series

What is MQSeries MQSeries is an component used to tie together different software applications so

that they can work together. This type of application is often known as business integration software

IBM’s middleware for commercial messaging and queuing. Available in 35 different platforms. Enable programs to communicate with each other across a network of unlike

components, such as processors, subsystems, operating systems and communication protocols.

MQSeries programs use a consistent application program interface (API) across all platforms.

Page 4: As400 Training Mq Series

MQSeries Platforms MQSeries supports 35 different platforms. Few of the platforms supported by

MQSeries are as listed below.

Lotus Notes AS/400 AT&T GIS UNIX Digital Open VMS HP-UX MVS/ESA SINIX or DC/OSx SUNOS OS/2 Warp Sun Solaris Windows Tandem NSK Windows NT AIX

Page 5: As400 Training Mq Series

Message Routing

A B

1. Program A puts a msg onto Q1

3. Program B puts a reply msg onto Q2

4. Program A gets the reply msg from Q2

2. Program B gets the msg from Q1

Page 6: As400 Training Mq Series

MQSeries - Basics

Links "nearly everything to almost anything..." Loosely-coupled flexibility via queuing Programs communicate by sending data in messages, and not by calling directly Faster and safer application development Common, ease-to-use, multi-platform API Assured message delivery Time Independence

Queue

1

A

B

Queue

2

Page 7: As400 Training Mq Series

Messages and Queues Some definitions & concepts

A Message is: A Unit of Information A Request for Service A Reply or Report An Announcement or Broadcast Audio or Video

A Queue is: A Safe Place to hold Messages A Message can be protected: Across the network or System failures

Page 8: As400 Training Mq Series

Messages and Queues Contd. Message Persistence - Persistent - Non Persistent Access to messages - FIFO - Priority - Direct 100 Mb maximum message length (V5) A large message can be segmented into a

number of smaller ones

A queue can be:

- Predefined

- Created dynamically by an application

More than one application can access a queue

Page 9: As400 Training Mq Series

MQ Messages

Header: A series of message attributes understood and augmented by the Queue Manager, such as: target queue name, length of user data, message priority, reply-to queue name....etc.

Message = Header + User Data

Header User Data

User Data: Any sequence of bytes Private to the sending and receiving programs Not meaningful to the Queue Manager

Page 10: As400 Training Mq Series

MQ Message types Message type Request/Reply An application places a message on a queue and expects a reply in return. This

does not necessarily imply synchronous operation, as the process receiving the reply may be separate from the requester.

Datagram (Fire&Forget) A datagram message is a message placed on a queue, for which no reply is

expected.

Report A report is a message generated by the queue manager if requested by the

application on completion of an event.

Page 11: As400 Training Mq Series

MQSeries Objects

Queue Manager The queue manager is an interface to messages and queues. For an application to use MQ, it must first connect to a queue manager. It is possible to run more than one queue manager on the same machine, although

this often causes confusion when testing applications.

Page 12: As400 Training Mq Series

MQSeries ObjectsQueues Queue is a data structure used to store messages.

It is the most frequently used object type and it is owned by the queue manager.

Queues can be defined as local or remote,

An application may create a queue dynamically.

Page 13: As400 Training Mq Series

MQSeries Objects Types of Queues:

Local queues Remote queues Transmission Queue Model Queue Dynamic Queue Event Queue Initiation Queue Dead Letter Queue

Page 14: As400 Training Mq Series

MQSeries Objects Channel A channel is defined between two queue managers. Channels are uni-directional. It may be the case that a remote queue exists on a queue manager that is more

than one “hop” away.

Page 15: As400 Training Mq Series

Deeper Look at how it works

Message Queue Manager

MessageChannelAgent

Message Queue Manager

MessageQueuingService

MessageChannelAgent

MQSeriesInterface

MQSeriesInterface

Q1 Q2

XMIT

QNetwork

MessageQueuingService

Appl A

PUT MSG

Appl B

GET MSG

Appl C

GET MSG

Page 16: As400 Training Mq Series

Typical Workflow

Page 17: As400 Training Mq Series

Explanation of the workflowAn MQ application, connected to queue manager QM1, puts a message on a remote

queue Q2 managed by queue manager QM2. The message is immediately placed on a transmit queue.

The Message Channel Agent (MCA) gets the message from the transmit queue.

The two MCA’s negotiate with each other, and the MQ “channel” is started. Channels can be configured to be open all the time, or to start when a message arrives on a transmit queue.

The receiving MCA inspects the message and determines where to place it. If the message is destined for a different queue manager, it would be placed on another transmit queue, and another channel to that queue manager would be negotiated.

The message is now available on the local queue, ready for application on QM2 to process.

Page 18: As400 Training Mq Series

MQSeries Trigger MQSeries triggering enables a program to be started automatically when

messages arrive on a queue. You can set trigger conditions on a queue so that a program is started to process that queue:

When the first message arrives on the queue When the number of messages on the queue reaches a predefined number Every time a message arrives on the queue

Page 19: As400 Training Mq Series

MQ-Series Trigger

Page 20: As400 Training Mq Series

MQSeries Features Single multiplatform API

Assured message delivery

Indirect program to program communications

Time Independence

Programs communicate by sending data in messages, and not by calling directly.

Indirect communication

Programs communicate thru Queues

Page 21: As400 Training Mq Series

MQI Calls MQI is IBM's message queuing API. Originally published as part of IBM's Open

Blueprint, the interface consists of the following 11 program calls:

MQCONN - connects an application to a particular queue manager.

MQOPEN - opens an MQSeries object, such as a queue, and returns a handle for use in subsequent calls.

MQGET - attempts to retrieve messages from a local queue opened earlier for input.

MQPUT - writes messages onto local or remote queues that have previously been opened for output.

MQPUT1 - a sequence of MQOPEN, MQPUT of one message and MQCLOSE.

Page 22: As400 Training Mq Series

MQI Calls Cont.. MQCLOSE - It gives up access to an MQSeries object and, depending on the

options specified, can cause an object such as a dynamic queue and its contents to be destroyed.

MQDISC - breaks the connection previously established with a particular MQSeries queue manager.

MQINQ - selectively inquires about a variety of MQSeries object attributes. MQSET - allows certain MQSeries object attributes to be set or modified from an

application. MQCMIT - indicates to the queue manager that the application has reached a sync

point and that all gets and puts since the last sync point are to be made permanent. MQBACK - indicates to the queue manager that it should roll-back all gets and puts

that have occurred since the last sync point.

Page 23: As400 Training Mq Series

Sample MQI CallMQCONN

CALL 'MQCONN' USING W02-MQM W03-HCONN W03-COMPCODE W03-REASON END-CALL.

Page 24: As400 Training Mq Series

MQI Calls Cont..

Page 25: As400 Training Mq Series

MQCONN

Page 26: As400 Training Mq Series

MQOPEN

Page 27: As400 Training Mq Series

MQCLOSE

Page 28: As400 Training Mq Series

MQDISC

Page 29: As400 Training Mq Series

MQPUT

Page 30: As400 Training Mq Series

Fields in Message descriptor

Page 31: As400 Training Mq Series

MQGET

Page 32: As400 Training Mq Series

MQGET message options

Page 33: As400 Training Mq Series

MQPUT1

Page 34: As400 Training Mq Series

MQINQ

Page 35: As400 Training Mq Series

MQSET

Page 36: As400 Training Mq Series

Return CodesA completion code and a reason code are returned as output parameters by

each call. These are known collectively as return codes.

The completion code is usually either MQCC_OK or MQCC_FAILED, showing success and failure, respectively. Some calls can return an intermediate state, MQCC_WARNING, indicating partial success.

There are many reason codes, covering circumstances as a queue being full, get operations not allowed, and a queue not being defined. ( MQRC_NONE, MQRC_NOT_AUTHORIZED, MARC_Q_MGR_NOT_AVAILABLE)

When the completion code is MQCC_OK, the reason code is always MQRC_NONE.

Page 37: As400 Training Mq Series

Message Persistence

Page 38: As400 Training Mq Series

Message Priority

Page 39: As400 Training Mq Series

Message and correlation identifier

Page 40: As400 Training Mq Series

Retrieving Message using selection criteria

Page 41: As400 Training Mq Series

Message Expiry

Page 42: As400 Training Mq Series

Impact of MQSeries on Application development

Wide selection of available platforms

Applications run in an asynchronous manner; parallelism

Assured delivery of information - anywhere in the network

Simpler and more rapid development of distributed or client/server applications

Limited number of calls with rich functions

Messaging means less networking

Page 43: As400 Training Mq Series

MQSeries – Lotus notes Application

Page 44: As400 Training Mq Series

MQSeries – Lotus notes Contd The Steps are Composes a document in the Lotus Notes user database. Activates a macro that includes the @MailSend function. This creates a new mail

memo, based on the information supplied in the arguments list, in the add-in task’s Mail-In database.

The add-in task periodically checks its own Mail-In Database, and removes the mail memo as soon as it is ready to process it.

The add-in task, using the name of the link database entry in the mail memo, refers to the information held in the link database to determine what action is required and what queues are to be used.

The add-in task then constructs an MQSeries message from the mail memo and places it on the queue named in the link database entry.

Page 45: As400 Training Mq Series

MQSeries – Lotus notes Contd If a reply is expected, the add-in task puts a message containing tracking and

control information, on its own work queue (it uses this information to process the reply).

The MQSeries application removes the message from the queue and processes it and places a reply on the reply queue..

The add-in task, after checking its Mail-In database, also checks those queues on which it is expecting reply messages (the names of which are held in the work queue).

The control information stored earlier on the work queue is removed and used.

The reply message data is used to update the original document on the Lotus