Basic concepts
For MQ, we need to know 4 nouns: Queue Manager, queue, message, channel; For programming designers, it is usually more about messages and queues, and for maintenance managers, the queue managers and channels are often more concerned. If we compare the queue Manager to a database, then the queue is one of the tables, and the message is a record in the table.
Queue: We can simply think of a queue as a container for storing messages.
Queue Manager: The Queue Manager builds a standalone MQ runtime environment, which is the manager of Message Queuing to maintain and manage Message Queuing.
Message: The smallest object in MQ; By default, the message can reach a default of 4MB. Messages can be broken into persistent messages and non-persistent messages. The so-called "persistent" meaning is whether the message can still be persisted after the MQ queue Manager restarts. Persistent messages are written to or read out of the queue and are recorded in log, so the performance is much worse than non-persistent messages.
Channel: A channel is a one-way point-to-point communication connection between two queue managers, and messages can only flow in one direction in a channel. The communication between queue managers is implemented by configuring channels, and the queue managers on both sides of the channel should be able to correspond to the relevant parameters of the channel. Different communication protocols can be configured on the channel, which makes the programming interface independent of the communication protocol. The configurations on both sides of the channel must match and have the same name, otherwise they cannot be connected.
RUNMQSC: Command line interface management tool; As a maintainer, we have two ways of dealing with MQ, one through the binary command tools provided by MQ (in the Bin directory of the MQ installation directory), and the other through command-line interaction management tools; but not completely replaceable; RUNMQSC is a generic MQ object management tool that uses the MQSC command set to manage MQ objects in all its aspects, and is the most direct and comprehensive way to manage them. The command set run by RUNMQSC is called MQSC (MQ Script command), and in RUNMQSC, all commands are converted to full capitalization before committing execution. So if you want to represent size-related strings, such as object names, enclose the string in quotation marks. Enter the following command to start the MQSC command: RUNMQSC [Queuemanagername]
--View the MQ version--
Dspmqver
--View queue status--
Dspmq
--Create a queue manager--
Crtmqm-q ECIS_QM
--Delete Queue Manager--
DLTMQM ECIS_QM
--Start the queue Manager--
STRMQM ECIS_QM
--Close the queue Manager--
Endmqm-i ECIS_QM immediately stop
Endmqm-p ECIS_QM Force Stop
--run Queue Manager--
RUNMQSC ECIS_QM
--Definition listener--
DEFINE LISTENER (LSR_4_ECIS_QM) trptype (TCP) PORT (1616) CONTROL (QMGR) REPLACE
START LISTENER (LSR_4_ECIS_QM)
--Define the channel--
DEFINE CHANNEL (ECIS. SVRCONN) Chltype (SVRCONN) MCAUSER (' MQM ') REPLACE
--Start channel--
Runmqchl–c chlname–m ECIS_QM
--Start listening--
Runmqlsr–t tcp–p 1616–m ECIS_QM
Endmqlsr-m ECIS_QM
--Define the queue--
DEFINE QL (q_svc2adp_4_telnet) REPLACE
DEFINE QL (Q_SVC2ADP_4_JDBC) REPLACE
DEFINE QL (q_svc2adp_4_http) REPLACE
DEFINE QL (Q_svc2adp_4_socket) REPLACE
--Delete queue--
Delete QL (q_svc2adp_4_telnet)
--View listener--
Display Listener (LSR_4_ECIS_QM)
--View channel--
Dis CHS (*)
--View channel--
Display QL (*) [ALL]
--View Queue Depth--
Display QL (q_svc2adp_4_http) curdepth
--Clear Queue message--
Clear QL (q_svc2adp_4_http)
--View ccsid--
Display Qmgr All
--Modify ccsid--
ALTER QMGR [Force] CCSID (5488)
Logical definition
##################################################
./jmsadmin
DELETE QCF (T_ECIS_QCF)
DELETE Q (t_ecis_q_svc2adp_telnet)
DELETE Q (t_ecis_q_adp2svc_telnet)
DELETE Q (T_ECIS_Q_SVC2ADP_JDBC)
DELETE Q (T_ECIS_Q_ADP2SVC_JDBC)
DELETE Q (t_ecis_q_svc2adp_http)
DELETE Q (t_ecis_q_adp2svc_http)
DELETE Q (T_ecis_q_svc2adp_socket)
DELETE Q (T_ecis_q_adp2svc_socket)
DEFINE QCF (T_ECIS_QCF) DESC () TRAN (CLIENT) HOST (10.151.128.13) QMGR (T_ECIS_QM) CHAN (T_ecis. SVRCONN) PORT (2626) CCSID (5488)
DEFINE Q (t_ecis_q_svc2adp_telnet) DESC () QMGR (T_ECIS_QM) QUEUE (q_svc2adp_4_telnet) CCSID (5488)
DEFINE Q (t_ecis_q_adp2svc_telnet) DESC () QMGR (T_ECIS_QM) QUEUE (q_adp2svc_4_telnet) CCSID (5488)
DEFINE Q (T_ECIS_Q_SVC2ADP_JDBC) DESC () QMGR (T_ECIS_QM) QUEUE (Q_SVC2ADP_4_JDBC) CCSID (5488)
DEFINE Q (T_ECIS_Q_ADP2SVC_JDBC) DESC () QMGR (T_ECIS_QM) QUEUE (Q_ADP2SVC_4_JDBC) CCSID (5488)
DEFINE Q (t_ecis_q_svc2adp_http) DESC () QMGR (T_ECIS_QM) QUEUE (q_svc2adp_4_http) CCSID (5488)
DEFINE Q (t_ecis_q_adp2svc_http) DESC () QMGR (T_ECIS_QM) QUEUE (q_adp2svc_4_http) CCSID (5488)
DEFINE Q (T_ecis_q_svc2adp_socket) DESC () QMGR (T_ECIS_QM) QUEUE (q_svc2adp_4_socket) CCSID (5488)
DEFINE Q (T_ecis_q_adp2svc_socket) DESC () QMGR (T_ECIS_QM) QUEUE (q_adp2svc_4_socket) CCSID (5488)
WebSphere MQ common Commands and Configuration
# #################################################
//Create local queue Q
define qlocal (q)
// Set the maximum depth of local queue Q to 5
ALTER qlocal (q) MAXDEPTH (5)
//recreate local queue Q if q already exists, reset all its properties to the default properties
DEFINE qlocal (q) replace
//Create remote queue
DEFINE QREMOTE (qrname) rname (AAA) rqmname (qmgrname) XMITQ (qtname)
//Create transmission queue
DEFINE qlocal (clv_hq_ TRAN) Usage (XMITQ) INITQ (SYSTEM. CHANNEL. INITQ) Trigdata (REV_CLV) Trigtype (every) TRIGGER REPLACE
//Create Receive-side channel C
DEFINE Channel (c) chltype (RCVR)
// Create the sender channel C, connecting the IP for the 10.10.10.10 port for the 1414-channel connection to the transmission queue XQ
DEFINE channel (C) Chltype (SDR) CONNAME (' 10.10.10.10 (1414 ) ') XMITQ (XQ)
//Create requester channel
DEFINE Channel (D) Chltype (rqstr) CONNAME (' 10.10.10.10 (1414) ')
//create server channel
DEFINE Channel (D) Chltype (SVR) XMITQ (XQ1)
//Create server connection channel
DEFINE channel (E) Chltype (SVRCONN) REPLACE
Show All remote queues
Display Qremote (*)
Show All Channels
Display Channel (*)
Defining dead-letter queues
DEFINE qlocal (QUEUE) defpsist (YES) REPLACE
To set the queue manager's dead-letter queue
ALTER QMGR DEADQ (QUEUE)
Set the Maxchannels and Maxactivechannels properties (maximum number of connections)
##################################################
The Maxchannels and maxactivechannels represent the maximum number of channels that the Queue Manager allows to configure and the number of channels that are allowed to run concurrently, and the default value for Maxchannels is 100. The default value of Maxactivechannels is the same as maxchannels. If you have more than 100 concurrent channel connections, you need to modify both parameters. This is especially important for inter-client/server communication with large concurrency.
On the UNIX platform, modify the Qm.ini file to add the following (path:/VAR/MQM/QMGRS/HQ_SVR):
Channels:
Maxchannels = 3000 (maximum number of channels)
Maxactivechannels = 3000 (maximum number of active channels)
pipelinelength=2
Adoptnewmca=all
Then restart MQ
To define a persistence queue:
DEFINE qlocal (QNAME) defpsist (YES) REPLACE
Transport Queue Management
##################################################
1: Define the transmission queue
DEFINE qlocal (Q_transfer) USAGE (XMITQ)
Note:
Q_transfer: Transmission queue name
The following defines an input queue with a trigger
DEFINE qlocal (Q_transfer) USAGE (XMITQ) defpsist (YES) INITQ (SYSTEM. CHANNEL. INITQ) Trigdata (Dp_rchannel) REPLACE
Note:
Parameter 1: Transmission queue name (Q_transfer)
Parameter 5: Trigger data (Dp_rchannel), which is the channel to start after triggering.
2: Define triggers on the transmit to queue
Dpcis_q_transfer: Transmission queue
Trigger data: Dp_rchannel, that is: Send Channel, start the channel when triggered
Alter Qlocal (Dpcis_q_transfer) trigdata (' Dp_rchannel ') trigtype (every) TRIGGER initq (' SYSTEM. CHANNEL. INITQ ')
Remote Queue Management
##################################################
Define the remote queue definition by entering the following command:
Define Qremote (Q1) rname (Q1) rqmname (qm_apple) XMITQ (qm_apple)
Note:
Parameter 1: Queue name (Sender remote queue name)
Parameter 2: Remote queue (receiver's local receive queue name)
Parameter 3: Remote Queue Manager (receiver Queue Manager name)
Parameter 4: Transmission Queue (Sender transport queue name)
Channel Management
##################################################
1: Create receiver Channel
DEFINE CHANNEL (sdr_ TEST) chltype (RCVR) REPLACE
Define channel (Q_r_channel2) Chltype (RCVR) Replace
Note:
Parameter 1: Receiver channel name
Replace: Indicates that the channel has been replaced
2: Create Sender Channel
DEFINE CHANNEL (sdrname) chltype (SDR) CONNAME (' 100.100.100.215 (1418) ') XMITQ (qtname) REPLACE
The Chltype can be: SDR, SVR, RCVR, Rqstr, Clntconn, SVRCONN, CLUSSDR, and CLUSRCVR.
Define channel (Dp_rchannel) Chltype (SDR) conname (' 10.101.2.3 (1414) ') XMITQ (q_transfer) Replace
Note:
Channel name: Dp_rchannel (name of sender channel)
Transmission queue: Q_transfer (name of sender transport queue)
3: Start Channel
Start Channel (Qm_orange. Qm_apple)
4: View channel status
Dis CHS (*)
Listener Management
##################################################
1: Defining listeners
DEFINE LISTENER (TCPLS1) trptype (TCP) PORT (1414) REPLACE
2: Start listener
Start Listener (TCPLS1)
3: Display listener information
Display Listener (TCPLS1)
Create Trigger
##################################################
In general, there are two purposes of setting up MQ triggers, one is to automatically start the sending side channel, and the other is to monitor the queue message, and once a new message is found, the corresponding processing process is initiated using the trigger.
If you are using triggers to automatically start a send-side channel, using Method 1, if you are using triggers to start a user process, use Method 2
Method 1
A trigger is set on the transport channel, the trigger control is turned on, and the type is "first"
B the initial queue is SYSTEM.CHANNEL.INITQ, which is listed as an MQ-dedicated channel boot queue and does not need to start its trigger monitor manually
C trigger data is the send-side channel name, such as qag.50
D put the message test in the transport channel when the send-side channel is inactive
Method 2
A creates a trigger boot queue with a template of SYSTEM.DEFAULT.INITIATION.QUEUE
Runmqsc
Define Qlocal (MQ. Triger. Iniqueue) Like (SYSTEM. DEFAULT. Initiation. QUEUE)
B define process the so-called process is the trigger to trigger the program in this case the process name: Triger.program Application ID: "Notepad.exe"
C set a trigger on a queue, typically a local queue, open trigger control, type select "First", "per" or "based on number of messages" according to your own needs
D Initial Queue Select a trigger start queue created in a, for example, MQ.TRIGER.INIQUEUE, the process name is set to the process name defined in B, for example Triger.program
E start trigger monitor runmqtrm-m qagwy-q MQ. Triger. Iniqueue
F put messages in local queue for testing
Method 2 can also do the work of method 1 by changing the application identity in the process definition to runmqchl-m qagwy-c qag.50, but the dedicated channel boot queue is available in MQ.
The queue does not need to manually start the trigger monitor, so the method 1 is less than Method 2, the configuration is simple, so it is better to use the trigger to automatically start the send-side channel, or Method 1.
WebSphere MQ Basic Command