Thursday, 7 January 2016

IBM MQ Basics

This post include a summary on IBM WebSphere MQ Queue Managers, Queues , Channels and Messages. Knowing these concepts will help you to do simple tasks like creating a queue, sending and receiving messages from a queue.

1. Queue Managers

Queue manager is the top level object that holds in the network (Such as queues and channels).        Queue manager names must be unique. The main tasks done through a queue manager are,

Start channels
Process MQI calls
Create, delete, alter queues and channel definitions
Run a command server to process MQSC commands
Coordinator for all queue operations.

2. Queues

Queue holds the messages destined to it and send the messages to consumers in the receiving order. A queue has two defined limits.

Maximum number of messages that it can hold
Maximum length of a message.

There are several queue types that can be used with the IBM MQ. They are,

Local queue:
A local queue object identifies a local queue belonging to the queue manager to which the application is connected. All queues are local queues in the sense that each queue belongs to a queue manager and, for that queue manager, the queue is a local queue. Local queues allow programs to both put messages on , and get messages off.

There are again three types of specifications. They are:

Transmission queue 
Initiation queue
Dead Letter queue 

a. Transmission queue - This type of Queue Holds the message that is destined for Remote queue. Whenever communication link is available the message would be forwarded to that queue.

Transmission queues are  temporarily stores messages that are destined for a remote queue manager. You must define at least one transmission queue for each remote queue manager to which the local queue manager is to send messages directly.

b. Initiation queue - This local queue in which QMgr puts a message to start an application when certain conditions are satisfied.

c. Dead Letter queue - This Dead letter queue is used by QMgr and as well as other applications to put the message when they cant deliver the message to the destined queue.

Remote queue: 
Remote queue definitions are definitions on the local queue manager of queues that belong to another queue manager. To send a message to a queue on a remote queue manager, the sender queue manager must have a remote definition of the target queue. Remote queues only allow programs to put messages only.

Alias queue:
Alias queues are not actually queues; they are additional definitions of existing queues. another name for a local or remote queue.  Typically used to switch queue destinations without modifying program code.

Model queue:
A model queue defines a set of queue attributes that are used as a template for creating a dynamic queue. Dynamic queues are created by the queue manager when an application issues an MQOPEN request specifying a queue name that is the name of a model queue. The dynamic queue that is created in this way is a local queue whose attributes are taken from the model queue definition. The dynamic queue name can be specified by the application or the queue manager can generate the name and return it to the application. Dynamic queues defined in this way are either temporary queues, which do not survive product restarts, or permanent queues, which do

Cluster queue:
A cluster queue is a queue that has been shared in a cluster so that all of the queue managers in the cluster can put and get from the queue using cluster channels.

3.Channels

A channel is a communication link used by distributed queue managers. There are two categories of channel in MQ:

Message channels, which are unidirectional, and transfer messages from one queue manager to another.
A message channel can transmit messages in one direction only. If two-way communication is required between two queue managers, two message channels are required.

There are six 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)


MQI channels, which are bidirectional, and transfer MQI calls from a MQ client to a queue manager, and responses from a queue manager to a MQ client. 
There are two types of MQI channel : server-connection and client-connection.


4.Messages

A message any arbitrary data that one program wants to send to another. This data is called the application data. A message needs to include other information, such as its destination and possibly a return address. This type of data is called the message descriptor

There are four types of messages:

A request message is used by one program to ask another program for something (usually data). A request message needs a reply.

A reply message is used in response to a request message.

A one-way message, as you would expect, doesn’t need a reply, though it can carry data.

A report message is used when something unexpected occurs. For example, if the data in a reply message is not usable, the receiving program might issue a report message.


  • Most useful report messages are generated by the Queue Manager.  For example, Delivery confirmation.
  • Messages can have a “time-to-live”, called Expiry.  A message that has not been delivered before its expiration is removed (not given to an app)
  • What to do with undeliverable messages? Each queue manager can have a dead-letter queue.

  
A persistent message survives the restart of the queue manager. A non-persistent message does not survive a restart of the queue manager.Persistent messages are written out to logs and queue data files. If a queue manager is restarted after a failure, it recovers these persistent messages as necessary from the logged data. Messages that are not persistent are discarded if a queue manager stops, whether the stoppage is as a result of an operator command or because of the failure of some part of your system.


No comments: