internal void TruncateQueueCore(WsQueue theQueue)
 {
     RetryOnHCONNError(() =>
     {
         var pcfMsg = _messageAgent.NewRequest(MQC.MQCMD_CLEAR_Q);
         pcfMsg.AddParameter(MQC.MQCA_Q_NAME, theQueue.Name);
         _messageAgent.Send(pcfMsg);
     });
 }
Exemplo n.º 2
0
        internal MQReader(WsQueue queue, bool useTransaction, IdMatching filter, Conversion converter)
        {
            _queue         = queue;
            IdFilter       = filter;
            Converter      = converter;
            UseTransaction = useTransaction;
            var oqm = OpenQueueMode.ForBrowseAndRead;

            _IbmQueue = queue.OpenQueueCore(oqm);
        }
        public IQueue OpenQueue(string queueName, bool autoLoadInfo = false)
        {
            if (string.IsNullOrEmpty(queueName))
            {
                throw new ArgumentNullException(nameof(queueName));
            }

            try
            {
                var q = new WsQueue(this, queueName);
                if (autoLoadInfo)
                {
                    q.RefreshInfo();
                }
                return(q);
            }
            catch (MQException ibmEx)
            {
                throw ibmEx.ToMqException(AddExtraInfoToError);
            }
        }
        internal void SetQueuePutInhibitCore(WsQueue theQueue, GetPutStatus newStatus)
        {
            RetryOnHCONNError(() =>
            {
                Exception pcfError = null;

                if (WsSoftwareInfo.AvoidPCFWhenPossible == false)
                {
                    var pcfMsg = _messageAgent.NewRequest(MQC.MQCMD_CHANGE_Q);
                    pcfMsg.AddParameter(MQC.MQCA_Q_NAME, theQueue.Name);
                    pcfMsg.AddParameter(MQC.MQIA_Q_TYPE, theQueue.QueueTypeCore);
                    pcfMsg.AddParameter(MQC.MQIA_INHIBIT_PUT,
                                        newStatus == GetPutStatus.Inhibited ? MQC.MQQA_PUT_INHIBITED : MQC.MQQA_PUT_ALLOWED);

                    if (_messageAgent.TrySend(pcfMsg))
                    {
                        return;
                    }

                    pcfError = _messageAgent.LastError;
                }

                // fallback option

                try
                {
                    MQQueue mqQ    = OpenQueueCore(theQueue.Name, OpenQueueMode.ForSet);
                    mqQ.InhibitPut = newStatus == GetPutStatus.Inhibited ? MQC.MQQA_PUT_INHIBITED : MQC.MQQA_PUT_ALLOWED;
                    mqQ.Close();
                }
                catch (MQException ex)
                {
                    if (pcfError != null)
                    {
                        ex.Data.Add("PCFError", pcfError.ToString());
                    }
                    throw;
                }
            });
        }
Exemplo n.º 5
0
 internal WsMessage(MQMessage ibmM, WsQueue queueOwner) : this(ibmM)
 {
     Debug.Assert(queueOwner != null);
     Queue = queueOwner;
 }
        internal void RefreshQueueInfosCore(WsQueue theQueue)
        {
            RetryOnHCONNError(() =>
            {
                Exception pcfError = null;

                if (WsSoftwareInfo.AvoidPCFWhenPossible == false)
                {
                    var inquireQueueInfo = _messageAgent.NewRequest(MQC.MQCMD_INQUIRE_Q);
                    inquireQueueInfo.AddParameter(MQC.MQCA_Q_NAME, theQueue.Name);
                    inquireQueueInfo.AddParameter(MQC.MQIACF_Q_ATTRS, new[]
                    {
                        MQC.MQIA_Q_TYPE,
                        MQC.MQIA_USAGE,
                        MQC.MQCA_BASE_Q_NAME,
                        MQC.MQIA_MAX_Q_DEPTH,
                        MQC.MQIA_INHIBIT_GET,
                        MQC.MQIA_INHIBIT_PUT,
                        MQC.MQIA_DEF_PRIORITY,
                        MQC.MQCA_REMOTE_Q_MGR_NAME,
                        MQC.MQCA_REMOTE_Q_NAME,
                        MQC.MQCA_XMIT_Q_NAME
                    });

                    PCF.PcfMessage[] response;
                    if (_messageAgent.TrySend(inquireQueueInfo, out response))
                    {
                        var qType = response[0].GetIntParameterValue(MQC.MQIA_Q_TYPE);
                        theQueue.QueueTypeCore = qType;

                        var defPriority          = response[0].GetIntParameterValue(MQC.MQIA_DEF_PRIORITY);
                        theQueue.DefaultPriority = defPriority;

                        theQueue.Type = WsQueueType.Unknown;

                        // Make sure all necessary properties have a value as null in case of not set by code under
                        theQueue.ExtendedProperties.UnderlyingName   = null;
                        theQueue.ExtendedProperties.MaxDepth         = null;
                        theQueue.ExtendedProperties.OpenReadCount    = null;
                        theQueue.ExtendedProperties.OpenWriteCount   = null;
                        theQueue.ExtendedProperties.UncommittedCount = null;

                        switch (qType)
                        {
                        case MQC.MQQT_ALIAS:
                            theQueue.Type = WsQueueType.Alias;
                            theQueue.ExtendedProperties.UnderlyingName =
                                response[0].GetStringParameterValue(MQC.MQCA_BASE_Q_NAME);
                            break;

                        case MQC.MQQT_MODEL:
                            theQueue.Type = WsQueueType.Model;
                            theQueue.ExtendedProperties.MaxDepth = response[0].GetIntParameterValue(MQC.MQIA_MAX_Q_DEPTH);
                            break;

                        case MQC.MQQT_LOCAL:
                            theQueue.Type = response[0].GetIntParameterValue(MQC.MQIA_USAGE) == MQC.MQUS_TRANSMISSION
                                    ? WsQueueType.Transmission
                                    : WsQueueType.Local;
                            theQueue.ExtendedProperties.MaxDepth = response[0].GetIntParameterValue(MQC.MQIA_MAX_Q_DEPTH);
                            break;

                        case MQC.MQQT_REMOTE:
                            theQueue.Type = WsQueueType.Remote;
                            theQueue.ExtendedProperties.RemoteQueueName        = response[0].GetStringParameterValue(MQC.MQCA_REMOTE_Q_NAME);
                            theQueue.ExtendedProperties.RemoteQueueManagerName = response[0].GetStringParameterValue(MQC.MQCA_REMOTE_Q_MGR_NAME);
                            theQueue.ExtendedProperties.TransmissionQueueName  = response[0].GetStringParameterValue(MQC.MQCA_XMIT_Q_NAME);
                            break;
                        }

                        theQueue.PutStatus = response[0].GetIntParameterValue(MQC.MQIA_INHIBIT_PUT) ==
                                             MQC.MQQA_PUT_INHIBITED
                            ? GetPutStatus.Inhibited
                            : GetPutStatus.Allowed;

                        if (theQueue.Type != WsQueueType.Remote)
                        {
                            theQueue.GetStatus = response[0].GetIntParameterValue(MQC.MQIA_INHIBIT_GET) ==
                                                 MQC.MQQA_GET_INHIBITED
                                ? GetPutStatus.Inhibited
                                : GetPutStatus.Allowed;
                        }

                        if (theQueue.Type == WsQueueType.Local || theQueue.Type == WsQueueType.Transmission)
                        {
                            var inquireQueueStatus = _messageAgent.NewRequest(MQC.MQCMD_INQUIRE_Q_STATUS);
                            inquireQueueStatus.AddParameter(MQC.MQCA_Q_NAME, theQueue.Name);
                            inquireQueueStatus.AddParameter(MQC.MQIACF_Q_STATUS_ATTRS, new[]
                            {
                                MQC.MQIA_CURRENT_Q_DEPTH,
                                MQC.MQIA_OPEN_INPUT_COUNT,
                                MQC.MQIA_OPEN_OUTPUT_COUNT,
                                MQC.MQIACF_UNCOMMITTED_MSGS
                            });

                            response = _messageAgent.Send(inquireQueueStatus);

                            theQueue.Depth = response[0].GetIntParameterValue(MQC.MQIA_CURRENT_Q_DEPTH);
                            theQueue.ExtendedProperties.OpenReadCount =
                                response[0].GetIntParameterValue(MQC.MQIA_OPEN_INPUT_COUNT);
                            theQueue.ExtendedProperties.OpenWriteCount =
                                response[0].GetIntParameterValue(MQC.MQIA_OPEN_OUTPUT_COUNT);
                            theQueue.ExtendedProperties.UncommittedCount =
                                response[0].GetIntParameterValue(MQC.MQIACF_UNCOMMITTED_MSGS);
                        }
                        return; // use of PCF message is successfull
                    }

                    pcfError = _messageAgent.LastError;
                }

                // Fallback option

                try
                {
                    var mqQ = OpenQueueCore(theQueue.Name, OpenQueueMode.ForQuery);

                    theQueue.QueueTypeCore = mqQ.QueueType;

                    theQueue.Type = WsQueueType.Unknown;

                    // Make sure all necessary properties have a value as null in case of not set by code under
                    theQueue.ExtendedProperties.UnderlyingName   = null;
                    theQueue.ExtendedProperties.MaxDepth         = null;
                    theQueue.ExtendedProperties.OpenReadCount    = null;
                    theQueue.ExtendedProperties.OpenWriteCount   = null;
                    theQueue.ExtendedProperties.UncommittedCount = null;

                    switch (mqQ.QueueType)
                    {
                    case MQC.MQQT_ALIAS:
                        theQueue.Type = WsQueueType.Alias;
                        theQueue.ExtendedProperties.UnderlyingName = mqQ.BaseQueueName;
                        break;

                    case MQC.MQQT_MODEL:
                        theQueue.Type = WsQueueType.Model;
                        theQueue.ExtendedProperties.MaxDepth = mqQ.MaximumDepth;
                        break;

                    case MQC.MQQT_LOCAL:
                        theQueue.Type = mqQ.Usage == MQC.MQUS_TRANSMISSION
                                ? WsQueueType.Transmission
                                : WsQueueType.Local;
                        theQueue.ExtendedProperties.MaxDepth = mqQ.MaximumDepth;
                        break;

                    case MQC.MQQT_REMOTE:
                        theQueue.Type = WsQueueType.Remote;
                        break;
                    }

                    theQueue.PutStatus = mqQ.InhibitPut == MQC.MQQA_PUT_INHIBITED
                        ? GetPutStatus.Inhibited
                        : GetPutStatus.Allowed;

                    if (theQueue.Type != WsQueueType.Remote)
                    {
                        theQueue.GetStatus = mqQ.InhibitGet == MQC.MQQA_GET_INHIBITED
                            ? GetPutStatus.Inhibited
                            : GetPutStatus.Allowed;
                    }

                    if (theQueue.Type == WsQueueType.Local || theQueue.Type == WsQueueType.Transmission)
                    {
                        theQueue.Depth = mqQ.CurrentDepth;
                        theQueue.ExtendedProperties.OpenReadCount =
                            mqQ.OpenInputCount;
                        theQueue.ExtendedProperties.OpenWriteCount =
                            mqQ.OpenOutputCount;
                        theQueue.ExtendedProperties.UncommittedCount = "?"; // not possible without pcf message
                    }
                    mqQ.Close();
                }
                catch (MQException ex)
                {
                    if (pcfError != null)
                    {
                        ex.Data.Add("PCFError", pcfError.ToString());
                    }
                    throw;
                }
            });
        }
Exemplo n.º 7
0
 internal WsDump2(WsQueue queue)
 {
     _qSource = queue ?? throw new ArgumentNullException(nameof(queue));
 }
Exemplo n.º 8
0
 internal WsDump(WsQueue queue)
 {
     _qSource = queue ?? throw new ArgumentNullException(nameof(queue));
     _fiMqmd  = typeof(MQMessage).GetField("md", BindingFlags.NonPublic | BindingFlags.Instance);
 }