mqbasics-090728034046-phpapp01

31
Introduction to WebSphere MQ

Transcript of mqbasics-090728034046-phpapp01

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 1/31

Introduction to WebSphere MQ

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 2/31

What is Websphere MQ?

IBM WebSphere MQ is a family of network communicationsoftware products launched by IBM. It allows independent andpotentially non-concurrent applications on a distributed systems tocommunicate with each other.

A middleware product that implements a messaging and queuingframework.

Middleware - an intermediate software component that bridgesdissimilar computing environments.

¨ Unix, MVS, OS/400 Tandem, VMS, NT, etc.¨ SNA, NetBios, TCP/IP

¨ Cobol, C, JAVA

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 3/31

Messaging - programs communicate by sending data in

messages rather than by calling each other directly. Queuing - messages are put on queues in storage,

eliminating the need for programs to be logically connected.

A messaging and queuing framework is inherentlyASYNCHRONOUS!

Messaging means that programs communicate by sendingeach other messages (data), rather than by calling eachother directly.

Queuing means that the messages are placed on queues in

storage, so that programs can run independently of eachother, at different speeds and times, in different locations,and without having a logical connection between them.

Messaging and Queueing

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 4/31

 Asynchronous vs. Synchronous Communications

Synchronous: App sends request, then blocks until request isprocessed.

¨Requires service available at EXACTLY same time as client needs service.

Asynchronous: App sends request and checks at some future time if complete.

¨Service need not be available when client sends request 

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 5/31

Synchronous:  Adv/Dis Adv

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 6/31

 Asynchronous:  Adv/Dis Adv

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 7/31

Messaging Advantages

Messaging vs. Procedure Calls

As programmers, many of us think procedurally, so using proceduresis natural extension of how we think.

Messages are an abstract concept: harder for us to conceptualizerelationship between actions and messages!

We are free to concentrate on the design of the application itself.

We are no longer concerned with details of the environment.

Our application is suddenly portable and to some degree, extensible.

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 8/31

How Messaging &Queuing Works

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 9/31

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 10/31

Messaging and Queuing Characteristics

Three key facts about Messaging and Queuing differentiate it from other

communication styles:

1) Communicating programs can run at different times.

2) There are no constraints on application structure.

3) Programs are insulated from environmental differences.

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 11/31

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 12/31

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 13/31

 Applications Shielded from Environmental Differences

Dont care what OS is used.

Dont care what language theyre written in

Dont care what the underlying communication protocol is used.

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 14/31

WebSphere MQ

Objects

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 15/31

Queue Manager 

Controls access to queues:administration (create, delete, etc)

usage (Put, Get)

serves as transaction (syncpoint) coordinator for all queue operations.

Accessed through the Message Queue Interface (MQI)

Queue Managers have names (identities) that are UNIQUE in a

network (like host names).

Queue Manager 

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 16/31

Queues

MQSeries defines four types of queues. A queue instance is fully qualified by its queuemanager and queue name.

Local Queue - an actual queue for which storage is allocated.

Remote Queue - a definition of a queue on a different queue manager (actssomewhat like a pointer)

Alias Queue - another name for a local or remote queue. Typically used to switch

queue destinations without modifying program code.

Model Queue - a template whose properties are copied when creating a new dynamiclocal queue ( create queue xxx like queue yyy).

MQSeries Queues: Some PropertiesMaximum Message Size

Maximum Queue DepthHigh/Low FactorsEnable/Disable Put or Get Persistent/Not Persistent 

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 17/31

Local queues can generate events (messages) under certain

conditions (like queue full). These event messages can be used to trigger  the execution of a

program.

These events are called trigger messages. The queue on whichthey are put is called an Initiation Queue.

Process defines an application to an websphere MQ queue manager. A process definition object is used for defining applications to bestarted by a trigger monitor .

A trigger monitor is a program that listens on an initiation queue

and executes commands named in Process definitions.

Triggering is useful when you dont want to deploy long-runningprograms.

Events, Triggers, Process

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 18/31

Channels

provide a communication path between two queue managers on the same, or

different, platforms. A message channel can transmit messages in one direction only. If two-way 

communication is required between two queue managers, two messagechannels are required.

Message Channels are implemented by programs called Message Channel  Agents (MCA)

Types of message channels:

Sender - initiates connection to Receiver

Server - Accepts request to start from requester, then becomes Sender

Receiver - Passive; waits for initiation sequence form Sender

Requester - Active at start, then becomes Receiver Cluster-sender (used amongst Cluster Queue Managers)

Cluster-receiver (ditto)

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 19/31

How messages move across channels ?

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 20/31

WebSphere MQ:  Assured Delivery

If queues are persistent, and message is persistent, then MCAs will eventually deliver the message to the target queue, and target application will get it!

MCAs have recoverable state - theyre STATEFUL - and a connection- oriented protocol.

Message is not removed from xmit queue until partner MCA confirmsplacement on target queue

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 21/31

Messages consist of: Header (MQMD)

Used by Queue Manager and application to handling properties of the message User Data

The application-to-application data (payload)transparent to MQSeries

Messages: Some Properties Destination Queue Reply Queue name Time to live (expiry) Format   Correlation ID Persistence Report options

Messages can be individually designated persistent or non-persistent (persistent messages are logged to enable recovery)

Correlation ID - select which message to get from queue Segmented Messages - allows ending of VERY LARGE messages (> 100 MB)

Messages

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 22/31

Message types Request - used by one program to ask another program for

something (usually data). A request message needs a reply.

Reply - used in response to a request message.

A one-way message, as you would expect, doesnt need a reply,

though it can carry data.

A report message is used when something unexpected occurs, or togive extra information like:

message delivered to target queue

message taken by application

message not deliverable

message exceeded time-to-live

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 23/31

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 24/31

Transaction Support

Unit of recovery - a piece of work that changes data from one point 

of consistency to another. Syncpoint - A point of consistency (also called a or commit point). It 

is a moment at which all the recoverable data that an applicationprogram accesses is consistent.

Applications are responsible for delimiting the beginning and end of atransaction. How can messaging be coordinated with a data baseupdate?

MQ is X A compliant and can operate with other XA compliant systemsas either a transaction manager (coordinator) or resource manager

(particpant).Some examples: Sybase, DB2, Oracle.

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 25/31

Logging and Recovery

 All operations that affect the state of the Queue Manager and its objects are

logged to a log file. What is state?

Object definitions (queue manager, queues, processes, channels, etc)

Queue content (messages)

Message channel states are logged separately by each channel 

Two forms of Logging Circular   log records are written sequentially across several files, then

 wrap back to the first file.

Linear - log records are written sequentially across files. New files areallocated as current files fill. No automatic reuse of file space!

Observations:

Circular logging is easy to manage, but is fatal if log is damaged (hard tobackup circular logs!).

Linear logging is hard to maintain but provides for archiving of previous logs(still a problem if current log is damaged).

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 26/31

Queue Manager Operations

crtmqm -q host1/qm1creates a queue manager name qm1 on host1

Strmqm 

Starts queue manager

Dspmq

Lists all the queue managers

rummqscStarts queue manager scripting interface

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 27/31

Queue Operations

Define/Modify Queue

DEFINE QLOCAL('queue1') DESCR(Test Queue)Creates a local queue named queue1

DEFINE QLOCAL('queue1') REPLACE DESCR(Modifieddescription)

Modifies the queue1 description

DisplayingQueuesDISPLAY QLOCAL(*)

DISPLAY QLOCAL('queue1')

DISPLAY QLOCAL('queue1') ALL

DISPLAY QLOCAL('queue1') DEFPSIST DESCR CURDEPTH

 Altering Queue Definition

 ALTER QLOCAL('queue1') property 

DISPLAY QLOCAL('queue1')

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 28/31

Put messages onto queue

amqsput queue1Sample AMQSPUT0 start 

target queue is queue1

Read message from Queue

amqsbcg queue1 > queue1.txt Reads messages from queue and messages will not be removed from 

queue

Gets messages from queue and messages will be removed

amqsget queue1

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 29/31

 Alias queue

Creating alias QueuerunmqscDEFINE QALIAS('queue1. alias') TARGQ('queue1') DEFPSIST(YES) + DESCR(alias

to queue1: For persistent messages) AMQ8006: WebSphere MQ queue created.end2 : endOne MQSC command read.

No commands have a syntax error. All valid MQSC commands were processed.

Displaying Alias queuerunmqscDISPLAY QALIAS('queue1.persistent') TARGQ DEFPSIST DESCR

 AMQ8409: Display Queue details.QUEUE(queue1.persistent) TYPE(QALIAS)TARGQ(queue1) DEFPSIST(YES)DESCR(alias to queue1: For persistent messages)

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 30/31

Remote queue

DEFINE QREMOTE('host1/qm1.alias') RNAME('')RQMNAME('host1/qm1') +DESCR(queue manager alias tohost1/qm1')

 AMQ8006: WebSphere MQ queue created.

DISPLAY QREMOTE('host1/qm1.alias') RNAME RQMNAME DESCR AMQ8409: Display Queue details.

QUEUE(host1/qm1.alias) TYPE(QREMOTE) DESCR(queue manageralias to host1/qm1) RQMNAME(host1/qm1) RNAME( )

end

8/8/2019 mqbasics-090728034046-phpapp01

http://slidepdf.com/reader/full/mqbasics-090728034046-phpapp01 31/31

Channel and Listener

Creating sender channel (from SRC_QM to TGT_QM)

DEFINE CHL ('SRC_QM.TO.TGT_QM') CHLTYPE(SDR) TRPTYPE(TCP)+ CONNAME ('IP_address(port)') XMITQ('TGT_QM') DISCINT(0)

Creating receiver channel (on TGT_MQ)

DEFINE CHL ('TGT_QM.TO.SRC_QM') CHLTYPE(RCVR) TRPTYPE(TCP)

Creating listener on SRC_QM

DEFINE LISTENER(SRC_QM.listener) TRPTYPE (TCP) PORT(1414)