Program-to-program communication by sending and receiving
messages to and from the queue without having a logical connection between
them.
Queuing
Programs communicate with each other through queues.
There are 2 types of messaging
- Asynchronous Messaging – the sending program proceeds with its own processing without waiting for the reply of the message.
- Synchronous Messaging
Note: Programmer can’t specify the name of the target
application to which the message is sent. Instead, they specifies the target
Queue as each queue is associated with a program.
A Message has 2 part – Data & Message Header.
- Message Header(Message Descriptor) identifies the message(message ID) and contains information(attributes)
- Common attributes are message type, expiry time, correlation ID, priority and name of the queue for reply.
Message Segmenting and Queuing
- Segmenting a large message if it does not fit the queue and receiver can get the message in one piece or as multiple segments based on the buffer size.
- Programmer can even segment the messages and each segment is treated as a separate physical message. Thus several physical messages building one logical message.
- To reduce network traffic, sometimes many small messages are grouped together and sent to destination.
MQ Message Types
- Datagram – Message containing information, but no response is expected.
- Request – Message for which a reply is requested.
- Reply – Reply to a request message
- Report – A message that describes an event such as occurrence of error or confirmation or arrival or delivery.
Persistent vs Non-Persistent Messages
Deliveries of persistent messages are assured. They are
written into logs to survive system failures.
Message Descriptor
- Version – depends on MQ version and the platform in use.
- Message ID / Correlation ID – these fields are used to identity a specific request or reply.
- Persistent/Non-Persistent
- Priority
- Date and time
- Expiration Date (when is date is reached, MQGET is called and the message is discarded)
- Return address – (reply-to-queue or reply-to-queue manager)
- Format – sender can specify a value which receiver can use to decide whether data conversion is done or not.
- Sender application and type.
- Report options and Feedback Code – used for request information like confirmation of delivery
- Back out Counter
- Message Segment and Grouping
MQ Manager (MQM)
- Manages queues and message for the application
- Provided Message Queuing Interface (MQI) for communication between programs.
Program A ( via
MQPUT) — > Remote Queue --> CHANNEL --> Local Queue
--> Program B (via MQGET)
Program A (via MQPUT)
— > Shared Queue --> Program B (via MQGET)
Queue Manager Clusters
- MQM’s are joined together in clusters which may run in the same machine or different machine.
- They maintain a repository that contains the information about all the queue managers and queues in the cluster. (Full Repository)
- The un-clustered MQM’s manage a repository that contains the information of the objects they are interested in (Partial Repository)
- MQM uses special cluster channels to exchange information
Queue Manager Objects
- Queues
- Process Definitions
- Channels
Queues
Queues are classified as
- Local Queue – a real queue
- Remote Queue – structure describing a queue
- Transmission Queue – local queue with special purpose
- Initiation Queue – local queue with special purpose
- Dynamic Queue – local queue created on the fly to store intermediate results
- Alias Queue – not real queues but definitions in case you want alias names
- Dead-letter Queue – one for each queue manager to store the messages when handling situations like destination queue is full, dest queue doesn’t exist, message is too large, duplicate message sequence number etc.
- Reply-to Queue – specified in request message
- Model Queue – model for local queues
- Repository Queue – holds the cluster information
Process Definitions
Defines an application to a queue manager
Eg: the name of the program (and its path) to be triggered
when a message arrives for it.
MQ Channels
- Channels are used to send and receive messages between queue managers.
- Channels are classified into
Message Channels
- connects 2 queue managers via Message Channel Agents (MCA or movers)
- unidirectional
- Comprises of 2 MCAs, a sender and a receiver and a communication protocol.
- MCA is a program that transfers messages from transmission queue to communication link and vice versa
MQI Channels
- Message Queue Interface channel
- Connects MQ client to a MQM in the server machine.
- Bi-directional.
Listeners
Listeners are processes that accept network requests from
other queue managers, or client applications, and start associated channels.
Lab Work
Creating a queue manager called QM1
1. Create a queue
manager with the name QM1 :
crtmqm QM1
2. Start the
queue manager :
strmqm QM1
create a queue called LQ1
A queue is a WebSphere MQ queue manager object. There are
three ways to create WebSphere MQ objects:
- WebSphere MQ Explorer.
- Using a programmable interface.
1. Start the
scripting tool :
runmqsc QM1
2. Create a local
queue called LQ1 by typing the following MQSC command:
define qlocal(LQ1)
3. Stop the
scripting tool by typing the following MQSC command:
end
Displaying Queue Manager Status
To check the queue manager is running or not:
dspmq
QMNAME(QM1)
STATUS(Running)
Putting a message to the Queue LQ1
1. Use the amqsput
sample application to put a message to queue LQ1 :
amqsput LQ1 QM1
When the sample application starts, you see:
# amqsput LQ1 QM1
Sample AMQSPUT0 start
target queue is LQ1
Type Hello World and press Enter. You placed a message that
contains the text “Hello World” on the queue LQ1 managed by the queue manager
called QM1. To end amqsput, press Enter.
You see the following output:
amqsput LQ1 QM1
Sample AMQSPUT0 start
target queue is LQ1
Hello World
Sample AMQSPUT0 end
Getting messages from the Queue LQ1
Use the amqsget sample application to read a message on the
queue LQ1:
amqsget LQ1 QM1
When the sample application starts, you see:
# amqsget LQ1 QM1
Sample AMQSGET0 start
message
no more messages
Sample AMQSGET0 end
The amqsget application ends 30 seconds after reading the
message.
Thats how you test the functionality of messaging queue between two applications.
Some helpful commands to use in IBM-MQ
# Create a Queue Manager$ crtmqm QM1# start a queue manager$ strmqm QM1# connect to a Queue Manager$ runmqsc QM1# create a Queue in QM1$ define ql(LQ1)# start a Linstener, from runmqsc$ START LISTENER# check listener status$ DISPLAY LSSTATUS(*)# Create a server connection channel$ DEFINE CHANNEL(DEV.APP.SVRCONN) CHLTYPE(SVRCONN) TRPTYPE(TCP) DISCINT(3600) DESCR('Server-connection to Client')# check channel status$ DIS CHS( chanl_name)# refresh security$ REFRESH SECURITY TYPE(SSL)
Br,
Punit