Below we will try to understand the basic behaviour of MQ objects and their behaviour for message exchange.
Let's assume, we have a requirement where,
"A java based application is generating few messages and those messages are to be consumed by C based application."
To fulfill the above requirement, we need to setup below component from MQ End.
1. Queue Manager
2. Local Queue
3. A message putting application(put functionality)
4. A message consuming application(get functionality)
1. We have installed the MQ software on Windows/Linux platform. Please follow MQ Installation for setting up the environment.
2. We have also logged in as MQ administrator, so we don't need any further permission at queue & queue manager level. To understand more about permissions click MQ Authorizations.
Let's understand basic components of MQ Setup,
Queue Manager is an MQ object.
This is the first and foremost component to be created after MQ installation. It manages the MQ objects and their behaviour.
It also supports applications, which are trying to put and get the messages.
Local queue can be created after the queue manager is brought into running state.
Local queue holds the application messages till the receiving end program consumes them. We will understand more about it in further sections.
Put Application is a program which puts the message into a queue. This could be written in any programming language or a proprietary application.
Here, we are using MQ Explorer for putting the messages into the queue. MQ explorer is a Java based application developed on eclipse platform. It has the wide range options for administering and working with the MQ objects.
Get Application is an Application which consumes the messages from a Queue.
Here, we are referring to "amqsget" application which is provided by IBM by default with MQ installation. It is developed in C language.
Create a queue manager conforming to organization naming standards. For more on naming standards refer to, what are naming standards?
After creating a queue manager, check its status using,
To bring a queue manager into starting mode. We can't work with MQ if queue manager is not in running state. So, to start a queue manager
Check the queue manager status again. This is to make sure that queue manager is actually in running state.
With the above setup, we have finished the setup of the first component which is queue manager.
Now to work with local queue creation,
we have to get into MQSC (MQ Scripting) mode of the queue manager.
To define a local queue with default attributes,
To check whether queue is created or not and its properties, use "Display" command in runmqsc of queue manager.
The above command displays every property of Websphere MQ local queue. We will be discussing most of these things at different sections of issues.
Right now, we want to focus only on, 2 of the queue properties.
Curdepth ---> This will display the number of messages currently available in that particular local queue. This value is dynamic and can't be altered.
MaxDepth---> This property will give the maximum number of messages that can be stored in the queue. This value is static and can be changed.
2 : DISPLAY QLOCAL(KL.JAP1.MAP1.REQ1) CURDEPTH MAXDEPTH
We assume that one had already gone through the "basic MQ setup" and trying to test its functionality.
As you know that we have taken MQ explorer (Java Based Application) for putting the messages into WebSphere MQ queue. MQ Explorer is available for installation on Windows & Linux Platforms only. It's not there on other flavors of UNIX OS.
Open MQ Explorer as an Administrator
All Apps(All programs) --> IBM WebSphere MQ --> MQ Explorer -->Right click on it --> choose "Run As Administrator"
We can see MQ Explorer is launched.
Now, go to IBM WebSphere MQ --> Queue Managers --> click on "Queues"
We can see the list of queue already created within that queue manager.
Right click on Queue name and click on "Put Test Message"
Type a message and click on "Put message" button and message is now pushed to a local queue. It's that simple.
We can observe current depth increased to "1", indicating that one message is available in the queue.
We can put any number of messages into the queue and once it is done then click on the "close" button.
For the test, we have placed 3 messages in the queue. We can see that current queue depth is raised to "3".
To get the messages from a Queue with C based Application(amqsget).
To check curdepth of a Queue after getting Messages from a Queue
We can conclude that a java application and C application are able to exchange information with the help of MQ.