Пример #1
0
        public void PutMessage(string queueName, string messageBody, string messageId)
        {
            Logger.LogMessage($"Connect to QueueManager '{_settings.QueueManager}'...");

            var mqQMgr = MqQueueManager.InitQueueManager(_settings.Channel, _settings.Connection, _settings.QueueManager);

            MQQueue mqQueue;

            try
            {
                mqQueue = mqQMgr.AccessQueue(queueName, MQC.MQOO_OUTPUT | MQC.MQOO_INPUT_SHARED | MQC.MQOO_INQUIRE);
            }
            catch (MQException mqe)
            {
                Logger.LogMessage("MQQueueManager::AccessQueue ended with " + mqe);
                return;
            }

            var mqMsg = MqMessage.InitMqMessage();

            mqMsg.SetStringProperty("MessageId", messageId);
            Logger.LogMessage($"Send message to Queue '{queueName}'...");

            mqMsg.WriteString(messageBody);

            var mqPutMsgOpts = new MQPutMessageOptions {
                Options = MQC.MQPMO_SYNCPOINT
            };

            try
            {
                mqQueue.Put(mqMsg, mqPutMsgOpts);
                mqQMgr.Commit();

                mqQueue.Close();
                mqQMgr.Close();
            }
            catch (MQException mqe)
            {
                Logger.LogMessage("MQQueue::Put ended with " + mqe);
            }
        }
Пример #2
0
 public MqReceiver(MqSettings settings)
 {
     _settings = settings;
     _mqQmgr   = MqQueueManager.InitQueueManager(_settings.Channel, _settings.Connection, _settings.QueueManager);
 }