Sitemap
Alexsey Maslennikov

Alexsey Maslennikov

Just software engineer

IBM WebSphere MQ +.NET Application.

4 min readJul 8, 2021

Chapter I. Connect to server is Simple

When we need to connect two (and more) applications we can use different technologies:

TCP/IP Sockets

Web Services

REST API

And so on . . .

But main problem that arises in that process — derriving message between applications. And You know what happens …Connection may lost any time and You will newer get important message.

Here appears our Main Hero!
IBM WebSphere MQ

Main Idea of this product can be desсribed as following image

Press enter or click to view image in full size
Photo by Alvin Mahmudov on Unsplash

We need to make sure that one application get message from another with no matters what happened.
And IBM WebSphere MQ does it!

What this product based on ?

Queues

Press enter or click to view image in full size
Photo by Mihály Köles on Unsplash

To connect one application with another — we need queue for Sender (WebSpere MQ server on one side) and queue for Reciever (WebSphere MQ Server on other side)

What we need to do for it ?

Firstable we need to install WebSphere MQ Server (we do not describe it in this article). It may be install on any server that we can connect to.

Than WebSphere MQ Administrator create Queue for out application (from here we can read messages and here we can put messages).

Know what we need to write our code for connection to WebSphere MQ Queue?

Firstable we need to install on our IBM WebSphere MQ Client and make link to library in our application.

Link to IBM WebSpere MQ Client Library

As You can see — Our Project so simple and so fresh … )

What we need to know for connection to queue ?

Server Domain name (where WebSphere MQ Server exists)

WebSphere MQ Server port (usual it = 1414)

Our application Queue Name

Server Connection Channel Name

Protocol to use (currently =TCP)

We can write it in single connection string like this:

APPLICATIONSERVERCONN/TCP/WEBSPHEREMQDOMAINNAME/1414

where

APPLICATIONSERVERCONN=Server Connection Channel Name

Get Alexsey Maslennikov’s stories in your inbox

Join Medium for free to get updates from this writer.

TCP=Protocol to use (currently =TCP)

WEBSPHEREMQDOMAINNAME=Server Domain name (where WebSphere MQ Server exists)

1414=WebSphere MQ Server port (usual it = 1414)

So on . . .

How we start connection ?

Press enter or click to view image in full size
Full Method to open connetion

The goal of this method is to instatiate queue manager and queue object.

They are global variables in out example, but You can change it.

Firstable we format options to pass them to the open queue manager, that is how we make it

Press enter or click to view image in full size
Set options for queue manager

This is enum values from amqmdnet.dll library, we set:

MQC.HOST_NAME_PROPERTY = Server Domain name (where WebSphere MQ Server exists)

MQC.PORT_PROPERTY=WebSphere MQ Server port (usual it = 1414)

MQC.CHANNEL_PROPERTY=Server Connection Channel Name

MQC.TRANSPORT_PROPERTY=Protocol to use (currently =TCP)

MQC.SECURITY_EXIT_PROPERTY=Additional changel security program installed on WebSphere MQ Server (it is additional param — if You intreresting in it, it’ll tell You in others articles)

Then if we need to connect with special user = we can pass special user name and password:

Authentication options is optional

Now let’s init Queue Manager object

Press enter or click to view image in full size

We pass as out parameters — MQException object and Exception if inside method will rise errors.

Let’s look to implementation of InitQueueManger

Press enter or click to view image in full size

Wow — it’s so simple, really ?

Now let’s go further, let’s init our queue

Press enter or click to view image in full size

And look at it’s implemetation

Press enter or click to view image in full size

What open options we use?

Now after that we had Queue and Manager object instatiated!
It’s is so simple, but how we can use it ?

YOU WILL LEARN ABOUT IT in out next article ) If You Want)

Thanks!

--

--