websphere mq basics tutorial | basic websphere mq setupwith screenshots

11
Websphere MQ Basics Tutorial 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) Assumptions: 1. We have installed the MQ software on Windows/Linux platform. Please follow MQ Installation for setting up the environment.

Upload: abclearnn

Post on 12-Apr-2017

67 views

Category:

Education


7 download

TRANSCRIPT

Page 1: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

Websphere MQ Basics Tutorial

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)

Assumptions:

1. We have installed the MQ software on Windows/Linux platform. Please follow MQ

Installation for setting up the environment.

Page 2: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

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:

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:

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:

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.

Note:

Instead of MQ explorer, we can also use "amqsput" c program for putting the messages into

the queue. This is installed by default with MQ software installation.

Page 3: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

Get Application:

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.

Steps to create Application-QueueManager-Application setup:

Note:

Here we mostly focus on command line options and we will try to avoid graphical tools while

working with MQ objects.

Step:1 Create a queue manager conforming to organization naming standards. For more on naming

standards refer to, what are naming standards?

crtmqm DKLHYQM001

Step:2

After creating a queue manager, check its status using,

dspmq -m DKLHYQM001

QMNAME(DKLHYQM001)

STATUS(Ended immediately)

Step:3 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

strmqm DKLHYQM001

Step:4

Check the queue manager status again. This is to make sure that queue manager is actually in

running state.

Page 4: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

dspmq-m DKLHYQM001

QMNAME(DKLHYQM001)

STATUS(Running)

With the above setup, we have finished the setup of the first component which is queue

manager.

Step:5

Now to work with local queue creation,

we have to get into MQSC (MQ Scripting) mode of the queue manager.

runmqsc DKLHYQM001

5724-H72 (C) Copyright IBM Corp. 1994, 2009. ALL RIGHTS RESERVED.

Starting MQSC for queue manager DKLHYQM001..

Step:6 To define a local queue with default attributes,

DEFINE QLOCAL(KL.JAP1.MAP1.REQ1)

1 : DEFINE QLOCAL(KL.JAP1.MAP1.REQ1)

AMQ8006: WebSphere MQ queue created.

Step:7 To check whether queue is created or not and its properties, use "Display" command in

runmqsc of queue manager.

DISPLAY QLOCAL(KL.JAP1.MAP1.REQ1)

The above command displays every property of Websphere MQ local queue. We will be

discussing most of these things at different sections of issues.

Step:8

Right now, we want to focus only on, 2 of the queue properties.

Page 5: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

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.

DISPLAY QLOCAL(KL.JAP1.MAP1.REQ1) CURDEPTH MAXDEPTH

2 : DISPLAY QLOCAL(KL.JAP1.MAP1.REQ1) CURDEPTH MAXDEPTH

AMQ8409: Display Queue details.

QUEUE(KL.JAP1.MAP1.REQ1)

CURDEPTH(0)

TYPE(QLOCAL)

MAXDEPTH(5000)

Remember:

There are no messages and by default max depth of any queue is 5000.

To test above setup follow below steps:

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.

Note:

We can also use "amqsput" sample program provided by IBM for putting messages into the

queue.

Step :1 Open MQ Explorer as an Administrator

Page 6: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

Go to,

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.

Step 2: Right click on Queue name and click on "Put Test Message"

Page 7: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

Type a message and click on "Put message" button and message is now pushed to a local

queue. It's that simple.

Page 8: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

We can observe current depth increased to "1", indicating that one message is available in the

queue.

Page 9: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

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".

Page 10: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

Step:3 To get the messages from a Queue with C based Application(amqsget).

amqsget KL.JAP1.MAP1.REQ1 DKLHYQM001

Sample AMQSGET0 start

message < WELCOME TO KNOBLAB >

message < 24900342506712358974368548948 >

message <*%@!@)$%&*($#@!&%*^@%(!%*&# >

no more messages

sample AMQSGET0 end

Page 11: Websphere MQ Basics Tutorial | Basic WebSphere MQ Setupwith screenshots

Step:4 To check curdepth of a Queue after getting Messages from a Queue

DISPLAY QLOCAL(KL.JAP1.MAP1.REQ1) CURDEPTH

1 : DISPLAY QLOCAL(KL.JAP1.MAP1.REQ1) CURDEPTH

AMQ8409: Display Queue details.

QUEUE(KL.JAP1.MAP1.REQ1) TYPE(QLOCAL)

CURDEPTH(0)

We can conclude that a java application and C application are able to exchange information

with the help of MQ.