WebSphere MQ Basics Tutorial by WebSphere Library Basics of all the important topics in WebSphere MQ administration covering different queues, channels, trigerring, multi-hoping, log files, troubleshooting and others.
Joseph http://webspherelibrary.mp
WebSphere MQ Basics
2
Contents WebSphere MQ ............................................................................................................................................ 4 VERSIONS ...................................................................................................................................................... 4 MQ Objects ................................................................................................................................................... 4 QUEUE MANAGER ..................................................................................................................................... 4 QUEUE ....................................................................................................................................................... 4 TYPES OF QUEUES ................................................................................................................................. 4 TYPES OF LOCAL QUEUE:- ......................................................................................................................... 5 DEAD-LETTER QUEUE ............................................................................................................................ 5 TRANSMISION QUEUE........................................................................................................................... 6 CHANNELS ................................................................................................................................................. 6 TYPES OF CHANNELS ............................................................................................................................. 6 COMBINATION OF CHANNELS .................................................................................................................. 7 LISTENER ................................................................................................................................................... 7 MQI COMMANDS..........................................................................................................................................7 CONTROL COMMANDS ............................................................................................................................. 7 SCRIPT COMMANDS .................................................................................................................................. 8 CHANNEL STATES .......................................................................................................................................... 9 1.
RUNNING........................................................................................................................................... 9
2.
INACTIVE ...........................................................................................................................................9
3.
RETRYING ..........................................................................................................................................9
4.
PAUSED STATE .................................................................................................................................. 9
MULTI-HOPPING :-( gate way) ...................................................................................................................... 9 PROCEDURE TO CREATE MULTI-HOPPING:- ........................................................................................... 10 TRIGGERING ................................................................................................................................................ 10 Triggering types....................................................................................................................................... 10 CHANNEL TRIGGERING........................................................................................................................10 APPLICATION TRIGGERING.................................................................................................................. 11 COMMAND SERVER .................................................................................................................................... 12 CONTROL COMMANDS FOR COMMAND SERVER .................................................................................. 12 http://webspherelibrary.mp
WebSphere MQ Basics
3
USE OF COMMAND SERVER .................................................................................................................... 12 AUTHORIZATIONS ....................................................................................................................................... 12 COMMANDS TO SET AUTHORIZATIONS ................................................................................................. 13 TROUBLE SHOOTING METHODS ................................................................................................................. 13 LOGS ........................................................................................................................................................ 13 TRANSMISSION LOGS .......................................................................................................................... 13 ERROR LOGS:-...................................................................................................................................... 14 Creation of image backup by using linear logs: .......................................................................................... 15 MQ Client .................................................................................................................................................... 15 PERSISTENT AND NON-PERSISTENT MESSAGES ......................................................................................... 15 GENERAL ERRORS OCCURING IN REALTIME SCENARIO: ............................................................................. 15 Getting help on MQRC error codes ............................................................................................................. 15 About Author .............................................................................................................................................. 16 About WebSphere Library........................................................................................................................... 16 Contacts ...................................................................................................................................................... 16
http://webspherelibrary.mp
WebSphere MQ Basics
4
WebSphere MQ is an IBM web sphere product which is evolved in 1990s. MQ does transportation from one point to other. It is a middleware tool used for connectivity. Previously it was known with name mqseries. MQ supports more than 35+ operating systems. It is platform independent. For every OS we have different MQ software.
VERSIONS:- 5.0, 5.1, 5.3, 6.0, 7.0(Latest version). Currently widely used version is 6.2 MQ has two things, they are OBJECTS, SERVICES.
MQ 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 receives messages. 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 is used to store messages for programs that use the same queue manager. For Example, program A and program B each has a queue for incoming messages and another queue for outgoing messages. Since the 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 queue manager in a server machine. 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 different attributes or properties. Example:
Alias for LQ with different parameters DEFINE QALIAS (PQ) TARGQ (LQ) GET (DISABLED) PUT (ENABLED) http://webspherelibrary.mp
WebSphere MQ Basics
5
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 is created. Repository Queue
These are used in conjunction with clustering and hold either a full or a partial repository of queue managers and queue manager objects in a cluster (or group) of queue managers.
Remote Queue
The queue which holds the address of the remote queue manager where the message has to be sent or delivered. 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 Queue Remote queue-> Transmission queue-> Channel->Network receiver channel-> Local queue (finally the message will reach here) CHANNEL Channel (123.456) channel name. CHLTYPE (SDR) sender channel TRPTYPE (TCP) Transport type using TCP protocol CONNAME (127.0.0.1)(1414)the channel will connect to the IP address specified in the conn name and looks for the queue manager which is having listener, port number(1414) and connects to the queue manager. XMITQ (TQ)?the channel will receive the messages from transmission queue.
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
letter queue. 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 queue manager. http://webspherelibrary.mp
WebSphere MQ Basics
6
Note:- For one Queue manager we can.t have two dead letter queues. We have system defined objects called SYSTEM.DEAD.LETTER.QUEUE. Or we can use our own dead letter queue. The messages those are landed in the dead letter header (DLH). By seeing the dead letter header, we can find the reason and the destination.
RULE TABLE:-
Syntax:- DESTQ(DLQ) DESTQM(222) HEADER(NO) Runmqdlq:-rule table path
REASON(*)
WAIT(NO)
FWDQ(LQ)
FWDQM(222)
TRANSMISION QUEUE:- TQ will receive messages from Remote queue and hits or sends the
messages to the channel.
CHANNELS It is a Networked program to transmit or pas the messages over the network. Channel will receive the messages from XMITQ which is defined in the definition of the channel. Transmission queue is also a local queue. TYPES OF CHANNELS
. Message channels. . MQI Channels.
MESSAGE CHANNELS:- Message channels are one way piping channels. They are used for
sending or receiving 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 the
messages in both ways. TYPES of MQI Channels:. Server Connection Channel (SVRCONN) . Client Connection Channel (CLNTCONN)
http://webspherelibrary.mp
WebSphere MQ Basics
7
The MQ client will interact with MQ server using server connection (SVRCONN) or Client connection channel(CLNTCONN) On MQ client side we have three environmental variables 1. 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 CONNECTION CHANNEL(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 MQSERVER Result:- svr\tcp\127.0.0.1(1000)
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. 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 queue manager. 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 version . Dspmq :-to view all queue managers of MQ. . Crtmqm :-to create a queue manager http://webspherelibrary.mp
WebSphere MQ Basics
8
. 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, isteners to user or group . 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 every queue 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 for queue manager or object . RESET :-used to reset channel,cluster,queue manager . RESOLVE :-to resolve the channel which is in indoubt state http://webspherelibrary.mp
WebSphere MQ Basics
9
. 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 running state 2. 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 in disconnect 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 the receiver channel transportation type is different.. Etc.
4. PAUSED STATE:- this state is applicable for receiver (RCVR) channel. Paused state occurs when the receiving queue is full. Note:1. If we do any changes to the channels, listeners, queue manager, to effect the changes we need to stop and 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 MultiHopping. Note:For every queue, except remote queue we have two properties. open input count ( Iproess ) open output count ( Oprocss ) the application which is connected and putting the messages is called . O process . The application which is processing (getting) the messages is called I procss .
http://webspherelibrary.mp
WebSphere MQ Basics
10
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 (Remote Queue Manager) i.e Rname QM3 in RQMname and the transmission queue called XMITQ (TQ). Create a transmission queue called (TQ) Create a sender channel from (QM1.QM2) In Qm2 create, Create a receiver channel (QM1.QM2) Create a transmission queue with name target queue manager name called QM3. Create a sender channel from (QM2.QM3) with transmission queue called XMITQ (QM3) 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. 3. 4. 5. 6. 7. 8.
TRIGGERING:1. This is an automated event driven by MQ 2. Triggering is an event which occurs when specific conditions are met on a queue
Triggering types 1. CHANNEL TRIGGERING 2. APPLICATION TRIGGERING CHANNEL TRIGGERING: - channel triggering is an event which fires the channel whenever a
certain conditions are met on transmission queue. Disconnect Interval of a Channel :-It is an attribute or property of the channel(DISCINT).if the channel is idle 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 http://webspherelibrary.mp
WebSphere MQ Basics ALTER QLOCAL (TQ) TRIGGER TRIGTYPE (FIRST) TRIGDATA (111.222) (SYSTEM.CHANNEL.INITQ) If we want to remove the trigger condition put NO before trigger condition.
11
INITQ
CHANNEL TRIGGERING PROCESS:-
After giving specific conditions to a transmission queue, whenever the messages comes to the transmission queue, the queue manager will look at the queue, if it is triggered the queue manager will fire a trigger message in to initiation queue(SYSTEM.CHANNEL.INITQ) with the information called trigger type, trigger data, the channel which is to be fired. At the initiation queue (SYSTEM.CHANNEL.INITQ) channel initiator will be watching (monitoring) the initiation queue. Whenever 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 the channel (which is mentioned in the trigger data). Note:-MCA (message channel agent) is a program which is defined automatically whenever a queue manager is created. We have two types of MCA
. SENDER MCA(SDRMCA) . RECEIVER MCA(RCVRMCA)
APPLICATION TRIGGERING:- whenever specific conditions met on a local queue application
triggering works. TRIGGER CONDITION:. Trigger ON . Trigger type(first, every(t.type),depth) . Initiation queue(our own defined local queue) . Process
DEFINE 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. Whenever the message comes to triggered local queue, queue manager will fire trigger message with information called trigger type and the process definition (application which is to be triggered) in to the initiation 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. http://webspherelibrary.mp
WebSphere MQ Basics
12
3. Whenever the trigger message occurs in the initiation the trigger monitor will pick the information and starts the application which is defined in the process.
COMMAND SERVER:- it is a background process for queue manager when the queue manager starts command server will be running (default) Note: - we have one attribute (SCMDSERV) and we have two options in that 1. QMGR 2. MANUAL By 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.
CONTROL COMMANDS FOR COMMAND SERVER :. Dspmqcsv . Strmqcsv . Endmqcsv 1. Dspmqcsv: - to display the command server for particular queue manager Syntax:-dspmqcsv qmgrname E.g.:- Dspmqcsv QM1.qmgr
2. Strmqcsv:-to start the command server for a particular queue manager Syntax:-strmqcsv .a qmgrname Eg:-strmqcsv Qm1 3. Endmqcsv:-to end the command server for a particular queue manager Syntax:-endmqcsv .c .I qmgrname Eg :- 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 queue manager using (SYSTEM.ADMIN.COMMAND QUEUE). When the command server is stopped the commands, the commands will be stored in the command queue called (SYSTEM.ADMIN.COMMAND QUEUE). After command server comes up the commands would be executed those are in the command queue.
AUTHORIZATIONS:- MQ provides authorizations(permissions) for the users in two levels 1. Qmanager level 2. Object level
http://webspherelibrary.mp
WebSphere MQ Basics
13
MQMgroup:- This group is automatically created by MQ after installation. It also creates one user mqm. The users should belong to MQM group so that they can have all the permissions to administer MQ.
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] Example: 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 Setall
TROUBLE SHOOTING METHODS LOGS:- MQ has two types of logs 1 TRANSMISSION LOGS 1. 2. 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 manager Default 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 ]
http://webspherelibrary.mp
WebSphere MQ Basics
14
Transmission log types:1. CIRCULAR LOGS 2. LINEAR LOGS LINEAR LOGS: - In linear logs we can recover objects which are damaged and we can take
backup and clear the transactions. By using linear logs we can restart, recover and Image backup. In this we need some administrative tasks to 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 at Checkpoint (objects are LQ, TQ, and Channel.etc) 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 logs
Notes 1. 2. 3. 4.
In transaction logs we have log primary and log secondary. We can view log primary files but we cannot view log secondary Files. By default queue manager will take .Lp as 3 and .Ls as 2. We can define log primary files maximum up to 250 files and log Secondary files maximum up to 254 files. Log primary files maximum.250 Log secondary files maximum.254
ERROR LOGS:-
The operations going on(running) on MQ will be written to errorlogs. We have two types of error logs, 1. 1.MQ level 2. 2.Queue manager level errors Queue 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 ]
http://webspherelibrary.mp
WebSphere MQ Basics
15
MQ level errors :- the operations or errors which are occurring on MQ are considered as MQ level errors. Default path for windows :- [ C:]program files\IBM\Websphere mq\errors\log files ] Path for UNIX, LINUX, SOLARIS :- [ $/var/mqm/errors/logfiles ]
Creation of image backup by using linear logs:
Syntax:- rcdmqimg Rcdmqimg[-z] [-L] [-m Qmgrname ] .t objtype[generic object name] Rcdmqimg .m Qm1 .t queue LQ To 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
MQ Client :- The person or user or application trying to connect access MQ server or queue manager they need MQ client installed at their side
PERSISTENT AND NON-PERSISTENT MESSAGES:MQ differentiates between persistent and non-persistent messages. Delivery of persistent messages is assured; they are written to logs to survive system failures. Non-persistent messages cannot be recovered after a system restart.
GENERAL ERRORS OCCURING IN REALTIME SCENARIO:
Mqrc 2059 :- Qmanager not available mqrc 2058 :- Qmanager name error mqrc 2085 :-unknown object name mqrc 2035 :- Not authorized mqrc 2033 :-No message available.
Getting help on MQRC error codes : mqrc---mq reason code.
http://webspherelibrary.mp
WebSphere MQ Basics
16
About Author Joseph is a technical consultant for multiple WebSphere products. He has ~7 years of
experience in administration, troubleshooting and consulting. He has significant experience in architecture, strategy and leadership positions
About WebSphere Library
"WebSphere Library” is collection of blogs about WebSphere Application Server, WebSphere MQ,
WebSphere Message Broker, WebSphere Process Server, SOA and Middleware Open Source products. These blogs will mostly contain the work of our authors and sometimes includes references and links to good articles and blogs from internet.
Contacts You can reach our authors using any of the following Facebook : http://facebook.com/websphereLibrary Twitter: http://twitter.com/websphere_lib Email:
[email protected] About: http://webspherelibrary.mp
http://webspherelibrary.mp