IBM MQ for .NET - 1.0

Extension ID

com.castsoftware.dotnet.ibmmq

What’s new?

See IBM MQ for .NET - 1.0 - Release Notes for more information.

Description

This extension provides support for IBM MQ .NET APIs (see Links) which are responsible for sending and receiving operations on the systems.

In what situation should you install this extension?

If your C# application utilizes IBM MQ for messaging-related operations and the producer and consumer are handled using the C# language, and you want to modelize the producer and consumer links with appropriate objects and links, then you should install this extension.

Technology Libraries

Library Version Supported
IBMMQDotnetClientexternal link up to: 9.4.1
IBMXMSDotnetClientexternal link up to: 9.4.1

Compatibility

Core release Operating System Supported
8.4.x Microsoft Windows / Linux
8.3.x Microsoft Windows

Dependencies with other extensions

Some CAST extensions require the presence of other CAST extensions in order to function correctly. The IBMMQ .NET extension requires that the following other CAST extensions are also installed (this will be managed automatically by CAST):

Download and installation instructions

The extension will not be automatically downloaded and installed. If you need to use it, you should manually install it.

What results can you expect?

Objects

Icon Description
DotNet IBMMQ Queue Producer
DotNet IBMMQ Queue Consumer
DotNet IBMMQ Unknown Queue Producer
DotNet IBMMQ Unknown Queue Consumer
DotNet IBMMQ Topic Producer
DotNet IBMMQ Topic Subscriber
DotNet IBMMQ Unknown Topic Producer
DotNet IBMMQ Unknown Topic Subscriber
Link Type Source and Destination of link Supported APIs
callLink callLink between the caller C# method and the DotNet IBMMQ Queue Producer or DotNet IBMMQ Topic Producer objects Producer API’s support by IBMMQ :

IBM.WMQ.MQQueue.Put
IBM.WMQ.MQDestination.Put
IBM.WMQ.MQQueue.PutForwardMessage
IBM.XMS.IMessageConsumer.Receive
IBM.XMS.IMessageConsumer.ReceiveNoWait
callLink callLink between the DotNet IBMMQ Queue Consumer or DotNet IBMMQ Topic Subscriber objects and the caller C# method Consumer API’s support by IBMMQ :

IBM.WMQ.MQQueue.Get
IBM.WMQ.MQDestination.Get
IBM.WMQ.MQQueue.PutReplyMessage
IBM.XMS.IMessageProducer.Send

Example code scenarios

Producer APIs

.NET Queue Producer
using System;
using System.Collections;
using IBM.WMQ;

class Program
{	
   String queueName = "SingheMessageQueue1";
   String queueManagerName = "Local.Network.Q01";
   
   void PutMessages()
        {		
				
                properties = new Hashtable();
                properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);

                queueManager = new MQQueueManager(queueManagerName, properties);

                queue = queueManager.AccessQueue(queueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
                
                message = new MQMessage();
                message.WriteString(messageString);

                for (int i = 1; i <= numberOfMsgs; i++)
                {
                    queue.Put(message);
                }
                queue.Close();
                queueManager.Disconnect();
        }
    
}

.NET Topic Producer
using System;
using System.Collections;
using IBM.WMQ;

class Program
{  
   String queueManagerName = "LOCAL.SYSTEM.QM02";
   String topicName = "SYSTEM.DEF.TOPIC1";
   
   void PutMessages()
        {
                properties = new Hashtable();
                properties.Add(MQC.HOST_NAME_PROPERTY, hostName);
                properties.Add(MQC.PORT_PROPERTY, port);
                properties.Add(MQC.CHANNEL_PROPERTY, channelName);

                queueManager = new MQQueueManager(queueManagerName, properties);
                topic = queueManager.AccessTopic(topicName, "", MQC.MQTOPIC_OPEN_AS_PUBLICATION, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);

                message = new MQMessage();
                message.WriteString(messageString);

                for (int i = 1; i <= numberOfMsgs; i++)
                {
                    topic.Put(message);
                }

                topic.Close();
                queueManager.Disconnect();
        }
    
}

Consumer APIs

.NET Queue Consumer
using System;
using System.Threading;
using IBM.WMQ;

class SimpleGet
{		
		String queueName = "SingheMessageQueue1";
		String queueManagerName = "Local.Network.Q01";
        
		void GetMessages()
        {
				properties = new Hashtable();
                properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
                properties.Add(MQC.HOST_NAME_PROPERTY, hostName);
                properties.Add(MQC.PORT_PROPERTY, port);
                properties.Add(MQC.CHANNEL_PROPERTY, channelName);

                queueManager = new MQQueueManager(queueManagerName, properties);
                queue = queueManager.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
                
				for (int i = 1; i <= numberOfMsgs; i++)
                {
                    message = new MQMessage();
					queue.Get(message);
                    message.ClearMessage();
                }
				queue.Close();
                queueManager.Disconnect();
		
        }   
}

.NET Topic Subscriber
using System;
using System.Threading;
using IBM.WMQ;

class SimpleSubscribe
{		
		String queueManagerName = "LOCAL.SYSTEM.QM02";
		String topicName = "SYSTEM.DEF.TOPIC1";
		
        void GetMessages()
        {
                properties = new Hashtable();
                properties.Add(MQC.HOST_NAME_PROPERTY, hostName);
                properties.Add(MQC.PORT_PROPERTY, port);
                properties.Add(MQC.CHANNEL_PROPERTY, channelName);

                queueManager = new MQQueueManager(queueManagerName, properties);
				
				if (durability == "nondurable")
                    topic = queueManager.AccessTopic(topicName, null, MQC.MQTOPIC_OPEN_AS_SUBSCRIPTION, MQC.MQSO_CREATE | MQC.MQSO_FAIL_IF_QUIESCING);
                else if (durability == "durable")
                    topic = queueManager.AccessTopic(topicName, null, MQC.MQSO_CREATE | MQC.MQSO_FAIL_IF_QUIESCING | MQC.MQSO_DURABLE | MQC.MQSO_RESUME, null, "DurableSubscriptionName");
                
				message = new MQMessage();
                message.WriteString(messageString);

                int time = 1;
                for (int i = 1; i <= numberOfMsgs; i++)
                {
                    message = new MQMessage();
                    topic.Get(message);
                    message.ClearMessage();
                }
				topic.Close();
                queueManager.Disconnect();
        }
}

Cross Technology Java/.NET

.NET Producer
using System;
using System.Threading;
using IBM.WMQ;

class nmqsput
{
	static int Main(String[] args)
		{
			MQQueueManager mqQMgr;  
			MQQueue mqQueue;       
			MQMessage mqMsg;     
			MQPutMessageOptions mqPutMsgOpts;  
			int msgLen;      
			String message;        
			
			String queueName = "SharedQueueV1";
			String queueManagerName = "QM2";
			
			mqQMgr = new MQQueueManager(queueManagerName);
			mqQueue = mqQMgr.AccessQueue( queueName,MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING );
			
			bool isContinue = true;
			while (isContinue)
			{
				message = System.Console.ReadLine();
				msgLen = message.Length;

				if (msgLen > 0)
				{
					mqMsg = new MQMessage();
					mqMsg.WriteString( message );
					mqMsg.Format = MQC.MQFMT_STRING;
					mqPutMsgOpts = new MQPutMessageOptions();

					mqQueue.Put( mqMsg, mqPutMsgOpts );
				}
				else
				{
					isContinue = false;
				}
			}
			return (0);
			}
}
Java Consumer

public class SampleIBM_mq_client{
	 public static final String  HOST_NAME           = "localhost";
	    public static final int     PORT_NUMBER         = 1313;
	    public static final String  QUEUE_MANAGER_NAME  = "QM2";
	    public static final String  QUEUE_NAME          = "SharedQueueV1";
	    public static final String  LOGIN_USERNAME      = "theanh";
	    public static final String  LOGIN_PASSWORD      = "GMAIL";
	    
	    
	    public static void main(String[] args) {
	            MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
	            cf.setHostName(HOST_NAME);
	            cf.setPort(PORT_NUMBER);
	            cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
	            cf.setQueueManager(QUEUE_MANAGER_NAME);
	            cf.setChannel("SYSTEM.DEF.SVRCONN");

	            MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection(LOGIN_USERNAME, LOGIN_PASSWORD);
	            MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
	            MQQueue queue = (MQQueue) session.createQueue(QUEUE_NAME);
	            MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver((Queue) queue);

	            long uniqueNumber = System.currentTimeMillis() % 1000;
	            JMSTextMessage message = (JMSTextMessage) session.createTextMessage("random number: " + uniqueNumber);

	            connection.start();

	            JMSTextMessage receivedMessage = (JMSTextMessage) receiver.receive();
	            
	            receiver.close();
	            session.close();
	            connection.close();
	    }
}

Limitations

  • Objects will not be created if the evaluation fails to resolve the necessary parameter.
  • Analyzer might not be able to fetch Consumer/Producer Properties defined via environment variable or in properties/configuration files.