MQ v6 Tutorial

download MQ v6 Tutorial

of 10

Transcript of MQ v6 Tutorial

  • 8/8/2019 MQ v6 Tutorial

    1/10

    MQ v6 Tutorial

    MQ Series/MQ: - It is an IBM web sphere product which is evolved in 1990s. MQ series doestransportation from one point to other. It is an EAI tool (Middleware). Now it is renamed as WebSphereMQ.

    VERSIONS:-5.0, 5.1, 5.3, 6.0, 7.0(new version).Currently widely used version is 6.2Note: - MQ series supports more than 35+ operating systems. It is platform independent. For every OSwe have different MQ series softwares.

    MQ series deals with two things, they are OBJECTS, SERVICES.In OBJECTS we have QUEUES CHANNELS PROCESS AUTHENTICATION QUERY MANAGER.In SERVICES we have LISTENERS.

    Objects: - objects are used to handle the transactions with the help of services.

    QUEUE MANAGER maintains all the objects and services.

    QUEUE: it is a database structure which stores messages until the application or program receivesmessages.

    TYPES OF QUEUES:- Local Queue Alias Queue Model Queue Remote Queue Repository Queue

    Local Queue:-A queue is local if it is owned by the queue manager to which the application program is connected. It isused to store messages for programs that use the same queue manager. For Example, program A andprogram B each has a queue for incoming messages and another queue for outgoing messages. Sincethe queue manager serves both programs, all four queues are local.Note: Both programs do not have to run in the same workstation. Client workstations usually use a queuemanager in a server machine.

    Remote Queue:-The queue which holds the address of the remote queue manager where the message has to be sent ordelivered.It is a logical queue where we cannot store the messages and get the messages.

    Note: To send the messages we use only Remote Queue, none other than this

    Message Flow from remote QueueRemote queue-> Transmission queue-> Channel->Network receiver channel-> Local queue (finally themessage will reach here) CHANNEL Channel (123.456)channel name.CHLTYPE (SDR) sender channelTRPTYPE (TCP) Transport type using TCP protocolCONNAME (127.0.0.1)(1414)?the channel will connect to the IP address specified in the conn name and

  • 8/8/2019 MQ v6 Tutorial

    2/10

    looks for the queue manager which is having listener, port number(1414) and connects to the queuemanager.XMITQ (TQ)?the channel will receive the messages from transmission queue manager.

    ALIAS QUEUE:-Alias queues are not real queues but they are definitions. They are used to assign different names to the

    same physical queue.Advantages of alias queue allow multiple programs to work with the same queue but with differentattributes or properties.Example:

    Alias for LQ with different parametersDEFINE QALIAS (PQ) TARGQ (LQ) GET (DISABLED) PUT (ENABLED)DEFINE QALIAS (PQ) TARGQ (LQ) PUT (ENABLED) GET (DISABLED)DEFINE QLOCAL (LQ)

    MODEL QUEUE:-A model queue is not a real queue. It is a collection of attributes that are used when a dynamic queue iscreated.

    Repository Queue:-Repository queues have existed since Version 5.1 and Version 2.1 for OS/390. They are used inconjunction with clustering and hold either a full or a partial repository of queue managers and queuemanager objects in a cluster (or group) of queue managers.

    TYPES OF LOCAL QUEUE:- Dead letter Queue Transmission Queue Initiation Queue Local Queue.

    DEAD-LETTER QUEUE: - the enrooted (or) undelivered messages will be landed in to the dead letterqueue.We have one control command called runmqdlq.It is a control command which is used to route the

    messages through .rul table.This is called dead letter handler. It is important that we need a dead letter queue defined for every queuemanager.Note:- For one Queue manager we cant have two dead letter queues.We have system defined objects called SYSTEM.DEAD.LETTER.QUEUE. Or we can use our own deadletter queue. The messages those are landed in the dead letter header (DLH). By seeing the dead letterheader, we can find the reason and the destination.RULE TABLE:-Syntax:- DESTQ(DLQ) DESTQM(222) REASON(*) WAIT(NO) FWDQ(LQ) FWDQM(222) HEADER(NO)Runmqdlq:-rule table path

    TRANSMISION QUEUE:-TQ will receive messages from Remote queue and hits or sends the messagesto the channel.

    CHANNELS:-It is a Networked program to transmit or pas the messages over the network. Channel will receive themessages from XMITQ which is defined in the definition of the channel. Transmission queue is also alocal queue.

    TYPES OF CHANNELS:- Message channels. MQI Channels.

  • 8/8/2019 MQ v6 Tutorial

    3/10

    MESSAGE CHANNELS:-Message channels are one way piping channels. They are used for sending orreceiving the messages. Message channels are unidirectional.

    TYPES OF MESSAGE CHANNELS:- Sender Channel(SDR) Receiver Channel(RCVR)

    Server Channel(SVR) Requester Channel(RQSTR) Cluster Sender Channel(CLUSSDR) Cluster Receiver Channel(CLUSRCVR)

    MQI CHANNELS:-These channels are two way piping channels which can send and receive themessages in both ways.TYPES:- Server Connection Channel (SVRCONN) Client Connection Channel (CLNTCONN)

    COMBINATION OF CHANNELS:- Sender and Receiver Server and Requester Cluster sender and Cluster Receiver Server Receiver Sender Requester

    LISTENER:- It is a service of MQ series Every Queue Manager will have a listener defined with a unique port number. (Default port number is:-1414) Listener acts as a mediator between external application or queue managers connecting to the queuemanager. To contact the queue manager we should approach through Listener.

    MQI COMMANDS:-

    MQI Commands are of three types. CONTROL COMMANDS SCRIPT COMMANDS PCF (programmable command format) COMMANDS.

    CONTROL COMMANDS :-( case sensitive) Dspmqver :-to display MQ series version Dspmq :-to view all queue managers of MQ series. Crtmqm :-to create a queue manager Strmqm :-to start queue manager Runmqsc :-to enter in to particular queue manager Endmqm :-to end a queue manager Dltmqm :-to delete a queue manager

    Dspmqcsv :-to display command server Endmqcsv :-to end command server Strmqcsv :-to start command server Runmqlsr :-to run listener service Endmqlsr :-to end listener service Runmqchl :-to run a channel out of queue manager Runmqdlq :-to execute dead letter handle with the help of rule table Setmqaut :-to set authorizations for particular objects like queuemanager,queues channels, listeners touser or group

  • 8/8/2019 MQ v6 Tutorial

    4/10

    Dspmqaut :-to display authorization for particular user Dmpmqaut :-to dump authorization for particular user Runmqchi :-to run a channel initiator for particular queue manager Runmqtrm :-to run trigger monitor on initiation queue for particular queue manager Rcdmqimg :-to take objects (or) record image of a particular queue manager objects Rcrmqobj :-to recreate the mq objects which are already recorded

    Replace :-s

    SCRIPT COMMANDS:-After entering in to queue manager we can find script commands. Script commands are same for everyqueue manager. (These Commands should be used in CAPITAL LETTERS) DEFINE :-To define/create MQ manager objects like queue, Channels, process, and listener. ALTER :-to update or modify the existing objects DISPLAY :-to view all the properties of a particular object or to Display all objects DELETE :-to delete created objects CLEAR :-to clear the message from the queue END :-to come out of the queue manager PING :-to check whether other side channel / queue manager is ready to accept our request. START :- to start the particular channel or listener STOP :-to stop particular channel or listener REFRESH :-used to refresh the security every time after giving or executing, set mgr or command forqueue manager or object RESET :-used to reset channel,cluster,queue manager RESOLVE :-to resolve the channel which is in indoubt state SUSPEND :-to suspend a queue manager from a cluster environment RESUME :-to remove a queue manager from a cluster environment

    CHANNEL STATES: - Channel states are of 5 types Running Inactive Retrying Stopped Paused(receiver channel)

    1. RUNNING: - before going to Running state the status will be initialization and binding Initialization:-channel will initiate the listener Binding:-sender channel binds with receiver, after that it Goes to runningstate2. INACTIVE:-we have one attribute called disconnect interval (DISCINT) with 6000 milli seconds (default)and it can be changed as of our convenience. If the channel is idle for a particular period defined indisconnect interval, the channel will go to inactive state.3. RETRYING:-the channel goes to retrying state if the other side queue manager will not be available,network issue, may be listener not running, may be receiver channel is in pause state, and may be thereceiver channel transportation type is different. Etc.4. PAUSED STATE:- this state is applicable for receiver (RCVR) channel. Paused state occurs when thereceiving queue is full.Note:-

    1. If we do any changes to the channels, listeners, queue manager, to effect the changes we need to stopand then start them.2. Before starting a channel listener should be in active / running, we can check by pinging the channel.3. Ping is used to check whether the receiver is in active state or not.Syntax: - PING CHANNEL (CHANNEL NAME)

    MULTI-HOPPING :-( gate way)Passing the messages between more than one intermediate queue managers is called Multi-Hopping.Note:-

  • 8/8/2019 MQ v6 Tutorial

    5/10

    For every queue, except remote queue we have two properties.1. open input count ( Iproess )2. open output count ( Oprocss )3. the application which is connected and putting the messages is called O process 4. The application which is processing(getting) the messages is calles I procss

    PROCEDURE TO CREATE MULTI-HOPPING:-1. Create a queue manager QM1, QM2, QM3.2. Start the queue managers QM1, Create a remote queue with attributes local queue name (RemoteQueue Manager) i.e Rname QM3 in RQMname and the transmission queue called XMITQ (TQ).3. Create a transmission queue called (TQ)4. Create a sender channel from (QM1.QM2)5. In Qm2 create, Create a receiver channel (QM1.QM2)6. Create a transmission queue with name target queue manager name called QM3.7. Create a sender channel from (QM2.QM3) with transmission queue called XMITQ (QM3)8. In QM3 create a local queue called (LQ) which is defined in remote queue of QM1 Rqueue(QM1)9. Create a receiver channel (QM2.QM3)We should have two listeners in QM2 and QM3.

    GENERAL ERRORS OCCURING IN REALTIME SCENARIO:-1. Mqrc 2059 :- Qmanager not available2. mqrc 2058 :- Qmanager name error3. mqrc 2085 :-unknown object name4. mqrc 2035 :- Not authorized5. mqrc 2033 :-No message available.(mqrc---mq reason code)

    TRIGGERING:-1. This is an automated event driven by MQ series2. Triggering is an event which occurs when specific conditions are met on a queue3. Triggering are of two types1. CHANNEL TRIGGERING2. APPLICATION TRIGGERING

    CHANNEL TRIGGERING: - channel triggering is an event which fires the channel when ever a certainconditions are met on transmission queue.

    Disconnect Interval of a Channel :-It is an attribute or property of the channel(DISCINT).if the channel isidle for particular interval of time the channel will go to inactive state.(default time is 6000 milli seconds)

    TRIGGER CONDITIONS:- Trigger ON Trigger type(first(t.type),every, depth) Trigger data(channel name which is to be fired) Initiation queue(SYSTEM.CHANNEL.INITQ)In command prompt:-

    DEFINE QLOCAL (TQ) USAGE (XMITQ) TRIGGERTYPE (FIRST) TRIGDATA (111.222) INITQ(SYSTEM.CHANNEL.INITQ)To make changes use alter command

    ALTER QLOCAL (TQ) TRIGGER TRIGTYPE (FIRST) TRIGDATA (111.222) INITQ(SYSTEM.CHANNEL.INITQ)If we want to remove the trigger condition put NO before trigger condition.

    CHANNEL TRIGGERING PROCESS:-After giving specific conditions to a transmission queue, whenever the messages comes to the

  • 8/8/2019 MQ v6 Tutorial

    6/10

    transmission queue, the queue manager will look at the queue, if it is triggered the queue manager willfire a trigger message in to initiation queue(SYSTEM.CHANNEL.INITQ) with the information called triggertype, trigger data, the channel which is to be fired.

    At the initiation queue (SYSTEM.CHANNEL.INITQ) channel initiator will be watching (monitoring) theinitiation queue.When ever the trigger message comes to initiation queue, the channel initiator will read the information

    and initiates the sender MCA (message channel agent).the sender message channel agent will start thechannel (which is mentioned in the trigger data).Note:-MCA (message channel agent) is a program which is defined automatically whenever a queuemanager is created.We have two types of MCA SENDER MCA(SDRMCA) RECEIVER MCA(RCVRMCA)

    CHANNEL INITIATOR:-It is a process running on a queue manager when queue manager is in running state. For every queuemanager there will only one channel initiatorNote:- 1.In MQseries 5.3 we have to run this channel initiator as a separate process for every queuemanager.2.If we use & any process will run at background. this applicable for all.Syntax:- runmqchi m Qmanagername q initq.Example :- runmqchi m QM1 q SYSTEM.CHANNEL.INITQTo run channel initiator for queue manager QM1.In solaris / unix /linux /AIX we run the channel initiator as follows.Runmqchi m QM1 q SYSTEM.CHANNEL.INITQ &

    APPLICATION TRIGGERING:-when ever specific conditions met on a local queue application triggeringworks.

    TRIGGER CONDITION:- Trigger ON Trigger type(first, every(t.type),depth) Initiation queue(our own defined local queue)

    ProcessDEFINE QLOCAL (LQ) TRIGGER TRIGTYPE (EVERY) INITQ (IQ) PROCESS (NOTEPAD).DEFINE PROCESS (NOTEPAD) APPLICID (NOTEPAD.EXE) APPLTYPE (WINDOWS)Runmqtrm m QM1 q IQ

    BACKGROUND PROCESS:-1. When ever the message comes to triggered local queue, queue manager will fire trigger message withinformation called trigger type and the process definition (application which is to be triggered) in to theinitiation queue (IQ) (our own queue).2. At the initiation queue a long running time program called trigger monitor will be watching (monitoring)the initiation queue.3. Whenever the trigger message occurs in the initiation the trigger monitor will pick the information andstarts the application which is defined in the process.

    DEFINE PROCESS (NOTEPAD) APPLICID (NOTEPAD.EXE) APPLYTYPE (WINDOWS NT)

    COMMAND SERVER:-it is a background process for queue manager when the queue manager startscommand server will be running (default)Note: - we have one attribute (SCMDSERV) and we have two options in that1. QMGR2. MANUALBy default the queue manager command server will be under control of (QMGR)If we change the SCMDSERV attribute to manual then we need to start command server manually.

  • 8/8/2019 MQ v6 Tutorial

    7/10

    CONTROL COMMANDS FOR COMMAND SERVER:- Dspmqcsv Strmqcsv Endmqcsv1. Dspmqcsv: - to display the command server for particular queue manager

    Syntax:-dspmqcsv qmgrnameE.g.:- Dspmqcsv QM1.qmgr2. Strmqcsv:-to start the command server for a particular queue managerSyntax:-strmqcsv a qmgrnameEg:-strmqcsv Qm13. Endmqcsv:-to end the command server for a particular queue managerSyntax:-endmqcsv c I qmgrnameEg :- endmqcsv I QM1(queue manager)-c stops the command in a controlled manner.-I stop the command immediately.

    USE OF COMMAND SERVER:- The command server will allow commands to execute on a queuemanager using(SYSTEM.ADMIN.COMMAND QUEUE)When the command server is stopped the commands, the commands will be stored in the commandqueue called(SYSTEM.ADMIN.COMMAND QUEUE)

    After command server comes up the commands would be executed those are in the command queue.

    AUTHORIZATIONS:- MQseries provides authorizations(permissions) for the users in two levels1. Qmanager level2. Object levelMQMgroup:- This group is automatically created by MQseries after installation. It also creates one user(MUSR_MQADMIN)The users should belong to MQM group so that they can have all the permissions to administer MQseries.

    COMMANDS TO SET AUTHORIZATIONS:-Setmqaut:- this command is used to set the authorizations.Syntax:- setmqaut[-m qmgrname] [-n objname] t objtype [-p principal /-g group] [-s service component ]

    Dspmqaut :-to display the authorizations which are set to the queue manager.Syntax:-dspmqaut[-M qmgrname] [-n objname ] t objtype [-p principal/ -g group ] [-s service component]

    Dspmqaut m QM1 t qmgr p XX(new user)

    The entity XX have the following authorizations for object QM1 Inq Connect Altusr

    Crt Dlt Chg Dsp Setid SetallObject level :-Syntax:-Setmqaut m QM1 n LQ t queue pXX +put

  • 8/8/2019 MQ v6 Tutorial

    8/10

    Dspmqaut m QM1 n LQ t queue p XXThe setmqaut command completed successfully

    Semqaut m QM1 n(20.30) t channel pXX +allmqiRunmqsc QM1Starting MQSC for queue manager 1

    REFRESH CLUSTER REFRESH SECURITY(generally we refresh security)Result: web sphere security cache refreshed

    TROUBLE SHOOTING METHODS:LOGS:- MQseries have two types of logs1. TRANSMISSION LOGS2. ERROR LOGS

    TRANSMISSION LOGS:-the transactions like messages inbound(incoming) and outbound(outgoing)objects creation, permissions etc. are going to be written to the transaction logs for every queue managerDefault path for log files in Windows:-[ c:\programfiles\IBM\websphere MQ\log\QMGR(QM1)\active directory\log files ]Default path for log files in LINUX, UNIX, SOLARIS, AIX (other than windows):-[ $/var/MQM/log/Qm1/active/logfiles ]

    Transmission logs are of two types:-1. CIRCULAR LOGS2. LINEAR LOGS

    LINEAR LOGS: - In linear logs we can recover objects which are damaged and we can take backup andclear the transactions.By using linear logs we can restart, recover and Image backup. In this we need some administrative tasksto monitor the logs and to clear the logs.CHECKPOINT:-It is nothing but creation of objects, which are stored as a transaction and are stored atCheckpoint (objects are LQ, TQ, and Channeletc)Creation of queue manager in linear logging:-

    Syntax:-Crtmqm LL Lf 2048 Lp 10 LS 1 QM2 Lq to create a queue manager in linear logging Lf to specify the log file size Lp to specify the number of log primaries Ls to specify the number of secondary logsNote:-1. In transaction logs we have log primary and log secondary.2. We can view log primary files but we cannot view log secondary Files.3. By default queue manager will take Lp as 3 and Ls as 2.4. We can define log primary files maximum up to 250 files and log Secondary files maximum up to 254files.Log primary f iles maximum250Log secondary files maximum254

    Creation of image backup by using linear logs:Syntax:- rcdmqimgRcdmqimg[-z] [-L] [-m Qmgrname ] t objtype[generic object name]Rcdmqimg m Qm1 t queue LQTo recover or recreate:-Rcrmqobj? this command is used to recover the objects.Syntax:-rcrmqobj[-z] [-m Qmgrname] t objtype[generic objname]Eg:- rcrmqobj m Qm1 t q LQ

  • 8/8/2019 MQ v6 Tutorial

    9/10

    ERROR LOGS:-The operations going on(running) on MQ series will be written to errorlogs.We have two types of error logs,1.MQseries level2.Queue manager level errorsQueue manager level errors:-the operations and errors are written to the queue manager error folder.

    Default path for windows :[ c:\program files\IBM\websphere MQ\Qmgrs(QM1)\errors\logfiles ]Path for UNIX, LINUX, and SOLARIS:-[$/var/mqm/qmgrs/Qm1/errors/logfiles ]MQ series level errors :- the operations or errors which are occurring on MQ series are considered as MQseries level errors.Default path for windows :-[ C:]program files\IBM\Websphere mq\errors\log files ]Path for UNIX, LINUX, SOLARIS :-[ $/var/mqm/errors/logfiles ]

    MQ series Client :- The person or user or application trying to connect access MQseries server or queuemanager they need MQ series client installed at their side

    MQI channels :-The MQseries client will interact with MQ series server using server connection(SVRCONN) or Client connection channel(CLNTCONN)In MQ client sid ewe have three environmental variables1. MQSERVER ( MQI channels )2. MQCHLTAB ( MQI channel tables )3. MQCHLIB (MQI channel library )

    Creation of server connection channel :-DEFINE CHANNEL(SVR) CHLTYPE(SVRCONN) TRPTYPE(TCP) DESCR(SERVER CONNECTIONCHANNEL(not mandatory))Syntax:-Set mqserver=server connection channel name/trptype/IP address(port)Eg :- set Mq server=SVR\tcp\127.0.0.1(1000)

    Set MQSERVERResult:- svr\tcp\127.0.0.1(1000)

    PERSISTENT AND NON-PERSISTENT MESSAGES :-MQSeries differentiatesBetween persistent and non-persistent messages. Delivery of persistent messages is assured; they Arewritten to logs to survive system failures. In an AS/400 these logs are Journal Receivers.Non-persistent messages cannot be recovered after a system restart.

    How a Client Sends a Request:-The client starts a program that puts a message on a queue. For this function five MQSeries API calls areexecuted MQCONN to connect to the queue manager in the server

    MQOPEN to open the message queue QS1 for output MQPUT to put a message in the queue MQCLOSE to close the queue QS1 MQDISC to disconnect from the queue manager

    How the Client Receives a Reply :-The client program knows the name of its input queue, here QA1 or QB1. The application can use twomodes of communication: ConversationalIf the application uses this mode of communication with the server program, it waits for the message to

  • 8/8/2019 MQ v6 Tutorial

    10/10

    arrive before it continues processing. This means, the reply queue is open and an MQGET with waitoption has been issued.The client application must be able to deal with two possibilities: The message arrives in time. The timer expires and no message is there.