コード例 #1
1
ファイル: MQManager.cs プロジェクト: rex2002xp/WebSphereMQlib
        /// <summary>
        /// Connect to MQ Server
        /// </summary>
        /// <param name="strQueueManagerName">Queue Manager Name</param>
        /// <param name="strChannelInfo">Channel Information</param>
        /// <returns></returns>
        public MQMessageStatus ConnectMQ(string strQueueManagerName, string strChannelName, string strHostName, string port, string userName, string password)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();            
            string strReturn = string.Empty;

            queueProperties[MQC.HOST_NAME_PROPERTY] = strHostName;
            queueProperties[MQC.PORT_PROPERTY] = port;
            queueProperties[MQC.CHANNEL_PROPERTY] = strChannelName;
            queueProperties[MQC.USER_ID_PROPERTY] = userName;
            queueProperties[MQC.PASSWORD_PROPERTY] = password;

            try
            {
                queueManager = new MQQueueManager(strQueueManagerName, queueProperties);
                messageStatus.Message = "Connected Successfully";
                messageStatus.Status = true;
            }
            catch (MQException exp)
            {
                strReturn = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }
            catch (Exception exp)
            {
                strReturn = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }

            return messageStatus;
        }
コード例 #2
0
ファイル: MQManager.cs プロジェクト: mukesharora/WorkflowPOC
        /// <summary>
        /// Write Message to Local Queue
        /// </summary>
        /// <param name="strInputMsg">Text Message</param>
        /// <param name="strqueueName">Queue Name</param>
        /// <returns></returns>
        public MQMessageStatus WriteLocalQMsg(string strInputMsg, string strQueueName)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();
            string          strReturn     = string.Empty;

            SendQueueName = strQueueName;
            try
            {
                queue = queueManager.AccessQueue(SendQueueName,
                                                 MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
                message      = strInputMsg;
                queueMessage = new MQMessage();
                queueMessage.WriteString(message);
                queueMessage.Format    = MQC.MQFMT_STRING;
                queuePutMessageOptions = new MQPutMessageOptions();
                queue.Put(queueMessage, queuePutMessageOptions);
                strReturn = "Message sent to the queue successfully";

                messageStatus.Message = strReturn;
                messageStatus.Status  = true;
            }
            catch (MQException MQexp)
            {
                strReturn             = "Exception: " + MQexp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }
            catch (Exception exp)
            {
                strReturn             = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }
            return(messageStatus);
        }
コード例 #3
0
ファイル: MQManager.cs プロジェクト: mukesharora/WorkflowPOC
        /// <summary>
        /// Connect to MQ Server
        /// </summary>
        /// <param name="strQueueManagerName">Queue Manager Name</param>
        /// <param name="strChannelInfo">Channel Information</param>
        /// <returns></returns>
        public MQMessageStatus ConnectMQ(string strQueueManagerName, string strChannelName, string strHostName, string port, string userName, string password)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();
            string          strReturn     = string.Empty;

            queueProperties[MQC.HOST_NAME_PROPERTY] = strHostName;
            queueProperties[MQC.PORT_PROPERTY]      = port;
            queueProperties[MQC.CHANNEL_PROPERTY]   = strChannelName;
            queueProperties[MQC.USER_ID_PROPERTY]   = userName;
            queueProperties[MQC.PASSWORD_PROPERTY]  = password;

            try
            {
                queueManager          = new MQQueueManager(strQueueManagerName, queueProperties);
                messageStatus.Message = "Connected Successfully";
                messageStatus.Status  = true;
            }
            catch (MQException exp)
            {
                strReturn             = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }
            catch (Exception exp)
            {
                strReturn             = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }

            return(messageStatus);
        }
コード例 #4
0
ファイル: MQManager.cs プロジェクト: mukesharora/WorkflowPOC
        /// <summary>
        /// Get Message count from Local Queue
        /// </summary>
        /// <param name="strqueueName">Queue Name</param>
        /// <returns>Text Message</returns>
        public MQMessageStatus CheckLocalQMsg(string strQueueName)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();
            string          strReturn     = string.Empty;

            ReceiveQueueName = strQueueName;
            try
            {
                queue = queueManager.AccessQueue(ReceiveQueueName,
                                                 MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);

                strReturn             = Convert.ToString(queue.CurrentDepth);
                messageStatus.Message = strReturn;
                messageStatus.Status  = true;
            }
            catch (MQException MQexp)
            {
                strReturn             = "Exception: " + MQexp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }
            catch (Exception exp)
            {
                strReturn             = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }
            return(messageStatus);
        }
コード例 #5
0
ファイル: MQManager.cs プロジェクト: mukesharora/WorkflowPOC
        /// <summary>
        /// Read Message from Local Queue
        /// </summary>
        /// <param name="strqueueName">Queue Name</param>
        /// <returns>Text Message</returns>
        public MQMessageStatus ReadLocalQMsg(string strQueueName)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();
            string          strReturn     = string.Empty;

            ReceiveQueueName = strQueueName;
            try
            {
                queue = queueManager.AccessQueue(ReceiveQueueName,
                                                 MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
                queueMessage           = new MQMessage();
                queueMessage.Format    = MQC.MQFMT_STRING;
                queueGetMessageOptions = new MQGetMessageOptions();
                queue.Get(queueMessage, queueGetMessageOptions);
                strReturn = queueMessage.ReadString(queueMessage.MessageLength);

                messageStatus.Message = strReturn;
                messageStatus.Status  = true;
            }
            catch (MQException MQexp)
            {
                strReturn             = "Exception: " + MQexp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }
            catch (Exception exp)
            {
                strReturn             = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status  = false;
            }
            return(messageStatus);
        }
コード例 #6
0
ファイル: MQManager.cs プロジェクト: rex2002xp/WebSphereMQlib
        /// <summary>
        /// Write Message to Local Queue
        /// </summary>
        /// <param name="strInputMsg">Text Message</param>
        /// <param name="strqueueName">Queue Name</param>
        /// <returns></returns>
        public MQMessageStatus WriteLocalQMsg(string strInputMsg, string strQueueName)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();
            string strReturn = string.Empty;
            SendQueueName = strQueueName;
            try
            {
                queue = queueManager.AccessQueue(SendQueueName,
                  MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
                message = strInputMsg;
                queueMessage = new MQMessage();
                queueMessage.WriteString(message);
                queueMessage.Format = MQC.MQFMT_STRING;
                queuePutMessageOptions = new MQPutMessageOptions();
                queue.Put(queueMessage, queuePutMessageOptions);
                strReturn = "Message sent to the queue successfully";

                messageStatus.Message = strReturn;
                messageStatus.Status = true;
            }
            catch (MQException MQexp)
            {
                strReturn = "Exception: " + MQexp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }
            catch (Exception exp)
            {
                strReturn = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }
            return messageStatus;
        }
コード例 #7
0
ファイル: MQManager.cs プロジェクト: rex2002xp/WebSphereMQlib
        /// <summary>
        /// Get Message count from Local Queue
        /// </summary>
        /// <param name="strqueueName">Queue Name</param>
        /// <returns>Text Message</returns>
        public MQMessageStatus CheckLocalQMsg(string strQueueName)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();
            string strReturn = string.Empty;
            ReceiveQueueName = strQueueName;
            try
            {
                queue = queueManager.AccessQueue(ReceiveQueueName,
                  MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);

                strReturn = Convert.ToString(queue.CurrentDepth);
                messageStatus.Message = strReturn;
                messageStatus.Status = true;
            }
            catch (MQException MQexp)
            {
                strReturn = "Exception: " + MQexp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }
            catch (Exception exp)
            {
                strReturn = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }
            return messageStatus;
        }
コード例 #8
0
ファイル: MQManager.cs プロジェクト: rex2002xp/WebSphereMQlib
        /// <summary>
        /// Read Message from Local Queue
        /// </summary>
        /// <param name="strqueueName">Queue Name</param>
        /// <returns>Text Message</returns>
        public MQMessageStatus ReadLocalQMsg(string strQueueName)
        {
            MQMessageStatus messageStatus = new MQMessageStatus();
            string strReturn = string.Empty;
            ReceiveQueueName = strQueueName;
            try
            {
                queue = queueManager.AccessQueue(ReceiveQueueName,
                  MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
                queueMessage = new MQMessage();
                queueMessage.Format = MQC.MQFMT_STRING;
                queueGetMessageOptions = new MQGetMessageOptions();
                queue.Get(queueMessage, queueGetMessageOptions);
                strReturn = queueMessage.ReadString(queueMessage.MessageLength);

                messageStatus.Message = strReturn;
                messageStatus.Status = true;
            }
            catch (MQException MQexp)
            {
                strReturn = "Exception: " + MQexp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }
            catch (Exception exp)
            {
                strReturn = "Exception: " + exp.Message;
                messageStatus.Message = strReturn;
                messageStatus.Status = false;
            }
            return messageStatus;
        }