Пример #1
0
        public override int Write(MQMessage message)
        {
            var num = 0;

            message.ClearMessage();
            message.MessageType   = 1;
            message.Expiry        = 0x3e8;
            message.Format        = MQC.MQFMT_ADMIN;
            message.Feedback      = 0;
            _mqCfh.ParameterCount = _list.Count;
            num += _mqCfh.Write(message);
            num += _list.Sum(parameter => parameter.Write(message));
            return(num);
        }
Пример #2
0
        protected MQMessage[] Send(int command, PcfParameter[] parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var oo            = MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_INQUIRE;
            var responseQueue = _qMgr.AccessQueue("SYSTEM.DEFAULT.MODEL.QUEUE", oo);

            var cmdMessage = new MQMessage {
                ReplyToQueueName = responseQueue.Name,
                MessageType      = MQC.MQMT_REQUEST,
                Feedback         = MQC.MQFB_NONE,
                Format           = MQC.MQFMT_ADMIN,
                Report           = MQC.MQRO_NONE
            };

            PCFAgentResponseTracker tracker;

            if (_qMgr.Platform == MQC.MQPL_ZOS)
            {
                tracker = new PCFAgentResponseTracker390();
                Mqcfh.Write(cmdMessage, command, parameters.Length, Cmqcfc.MqcftCommandXr, Cmqcfc.MqcfhVersion3);
            }
            else
            {
                tracker = new PCFAgentResponseTrackerNon390();
                Mqcfh.Write(cmdMessage, command, parameters.Length, Cmqcfc.MqcftCommand, Cmqcfc.MqcfhVersion1);
            }

            foreach (var p in parameters)
            {
                p.Write(cmdMessage);
            }

            var aqo      = MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE;
            var cmdQueue = _qMgr.AccessQueue(_qMgr.CommandInputQueueName, aqo);

            var pmo = new MQPutMessageOptions {
                Options = MQC.MQPMO_NEW_MSG_ID
            };

            cmdQueue.Put(cmdMessage, pmo);

            var gmo = new MQGetMessageOptions {
                Options      = MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_WAIT,
                WaitInterval = _waitInterval,
                MatchOptions = MQC.MQMO_MATCH_CORREL_ID
            };
            var list = new List <MQMessage>();

            while (true)
            {
                var response = new MQMessage {
                    CorrelationId = cmdMessage.MessageId
                };
                responseQueue.Get(response, gmo);

                list.Add(response);
                if (tracker.IsLast(response))
                {
                    break;
                }
            }
            cmdQueue.Close();
            responseQueue.Close();
            return(list.ToArray());
        }