Esempio n. 1
0
        private void WriteMessageDescriptor(MQMessageDescriptor md)
        {
            var ver = md.Version > 2 ? md.Version : 2;

            _sw.WriteLine("A VER {0}", ver.ToString(_culture));
            _sw.WriteLine("A RPT {0}", md.Report.ToString(_culture));
            _sw.WriteLine("A MST {0}", md.MsgType.ToString(_culture));
            _sw.WriteLine("A EXP {0}", md.Expiry.ToString(_culture));
            _sw.WriteLine("A FDB {0}", md.Feedback.ToString(_culture));
            _sw.WriteLine("A ENC {0}", md.Encoding.ToString(_culture));
            _sw.WriteLine("A CCS {0}", md.Ccsid.ToString(_culture));
            _sw.WriteLine("A FMT {0}", md.Format.ToString(_encoding));
            _sw.WriteLine("A PRI {0}", md.Priority.ToString(_culture));
            _sw.WriteLine("A PER {0}", md.Persistence.ToString(_culture));
            _sw.WriteLine("A MSI {0}", md.MsgId.ToHexString());
            _sw.WriteLine("A COI {0}", md.CorrelId.ToHexString());
            _sw.WriteLine("A BOC {0}", md.BackoutCount.ToString(_culture));
            _sw.WriteLine("A RTQ {0}", md.ReplyToQueue.ToString(_encoding));
            _sw.WriteLine("A RTM {0}", md.ReplyToQueueMgr.ToString(_encoding));
            _sw.WriteLine("A USR {0}", md.UserID.ToString(_encoding));
            _sw.WriteLine("A ACC {0}", md.AccountingToken.ToHexString());
            _sw.WriteLine("A AIX {0}", md.ApplIdentityData.ToHexString());
            _sw.WriteLine("A PAT {0}", md.PutApplType.ToString(_culture));
            _sw.WriteLine("A PAN {0}", md.PutApplName.ToString(_encoding));
            _sw.WriteLine("A PTD {0}", md.PutDate.ToString(_encoding));
            _sw.WriteLine("A PTT {0}", md.PutTime.ToString(_encoding));
            _sw.WriteLine("A AOX {0}", md.ApplOriginData.ToHexString());
            _sw.WriteLine("A GRP {0}", md.GroupID.ToHexString());
            _sw.WriteLine("A MSQ {0}", md.MsgSequenceNumber.ToString(_culture));
            _sw.WriteLine("A OFF {0}", md.Offset.ToString(_culture));
            _sw.WriteLine("A MSF {0}", md.MsgFlags.ToString(_culture));
            _sw.WriteLine("A ORL {0}", md.OriginalLength.ToString(_culture));
        }
Esempio n. 2
0
        public MQMessageDescriptor NewMQMD()
        {
            uint method = 0x2e8;

            this.TrEntry(method);
            MQMessageDescriptor result = new MQMessageDescriptor();

            base.TrExit(method, result);
            return(result);
        }
Esempio n. 3
0
        public void SetupCallback(MQCBD callbackDesc, int operation, MQMessageDescriptor callbackMsgDesc, MQGetMessageOptions callbackGetMsgOpts)
        {
            uint method = 0x594;

            this.TrEntry(method, new object[] { callbackDesc, operation, callbackMsgDesc, callbackGetMsgOpts });
            this.callbackDesc       = callbackDesc;
            this.callbackMsgDesc    = callbackMsgDesc;
            this.callbackGetMsgOpts = callbackGetMsgOpts;
            this.callbackRegistered = (operation & 0x100) != 0;
            this.callbackSuspended  = (operation & 0x10000) != 0;
            base.TrExit(method);
        }
Esempio n. 4
0
        internal void LogCurrentTransactionStart(byte[] xidBytes, MQXid xid, Guid queueManagerUid, int rmid, byte[] recinfo)
        {
            uint method = 0x52b;

            this.TrEntry(method, new object[] { xidBytes, queueManagerUid, rmid, recinfo });
            try
            {
                MQMessage mqMsg = new MQMessage();
                mqMsg.Persistence = 1;
                int     compCode = 0;
                int     reason   = 0;
                sbyte[] dst      = new sbyte[queueManagerUid.ToByteArray().Length];
                Buffer.BlockCopy(queueManagerUid.ToByteArray(), 0, dst, 0, dst.Length);
                base.TrText(method, "Qmid=" + NmqiTools.ArrayToHexString(queueManagerUid.ToByteArray()));
                sbyte[] numArray2 = new sbyte[recinfo.Length];
                Buffer.BlockCopy(recinfo, 0, numArray2, 0, numArray2.Length);
                base.TrText(method, "recordinfo=" + NmqiTools.ArrayToHexString(recinfo));
                sbyte[] numArray3 = new sbyte[xidBytes.Length];
                Buffer.BlockCopy(xidBytes, 0, numArray3, 0, numArray3.Length);
                base.TrText(method, "recordinfo=" + NmqiTools.ArrayToHexString(xidBytes));
                mqMsg.SetBytesProperty("dnet.XARECOVERY_QMID", dst);
                mqMsg.SetBytesProperty("dnet.XARECOVERY_RECINFO", numArray2);
                mqMsg.SetBytesProperty("dnet.XARECOVERY_XID", numArray3);
                mqMsg.SetIntProperty("dnet.XARECOVERY_RMID", rmid);
                mqMsg.SetDoubleProperty("dnet.XARECOVERY_TTIMEOUT", TransactionManager.MaximumTimeout.TotalMilliseconds);
                mqMsg.SetStringProperty("dnet.XARECOVERY_HOSTANDUSER", this.hostAndUser);
                this.marshal = new MQMarshalMessageForPut(mqMsg);
                mqMsg        = this.marshal.ConstructMessageForSend();
                byte[] sBuff           = mqMsg.GetBuffer();
                MQMessageDescriptor md = mqMsg.md;
                this.recoveryHconn.Session.MQFap.MQPUT(this.recoveryHconn, this.recoveryHobj.HOBJ, ref md, ref this.recoveryPutPmo, sBuff.Length, sBuff, null, 1, out compCode, out reason);
                base.TrText(method, "MessageId-" + NmqiTools.ArrayToHexString(md.MsgId));
                if (compCode != 0)
                {
                    base.throwNewMQException(compCode, reason);
                }
                this.TransactionLogList.Add(xid, mqMsg.md);
                this.marshal.Dispose(false);
                this.marshal = null;
                mqMsg        = null;
                sBuff        = null;
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 5
0
        internal void LogCurrentTransactionEnd(MQXid xid, int rmid)
        {
            uint method = 0x52c;

            this.TrEntry(method, new object[] { xid, rmid });
            MQMessageDescriptor msgDesc = new MQMessageDescriptor();

            msgDesc.Version = 2;
            try
            {
                if (this.TransactionLogList.ContainsKey(xid))
                {
                    MQMessageDescriptor descriptor2 = (MQMessageDescriptor)this.TransactionLogList[xid];
                    msgDesc.MsgId = descriptor2.MsgId;
                    base.TrText(method, "MessageId-" + NmqiTools.ArrayToHexString(msgDesc.MsgId));
                    int          dataLength   = 0;
                    int          bufferLength = 0x1000;
                    byte[]       buffer       = new byte[bufferLength];
                    int          compCode     = 0;
                    int          reason       = 0;
                    MQProxyQueue proxyQueue   = ((ManagedHobj)this.recoveryHobj.HOBJ).ProxyQueue;
                    if (proxyQueue != null)
                    {
                        proxyQueue.ProxyMQGET(msgDesc, this.recoveryGetGmo, bufferLength, buffer, ref dataLength, null, ref compCode, ref reason);
                    }
                    else
                    {
                        this.recoveryHconn.GetMQFAP.MQGET(this.recoveryHconn, this.recoveryHobj.HOBJ, msgDesc, this.recoveryGetGmo, bufferLength, buffer, out dataLength, out compCode, out reason);
                    }
                    if (compCode != 0)
                    {
                        base.throwNewMQException(compCode, reason);
                    }
                    this.TransactionLogList.Remove(xid);
                    buffer = null;
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }
Esempio n. 6
0
        public void InitializeForRecovery(Hashtable properties)
        {
            uint method = 0x51f;

            this.TrEntry(method, new object[] { properties });
            try
            {
                this.properties = properties;
                if (properties.ContainsKey(this.ConnectionName))
                {
                    this.connname_ = (string)properties["connectionName"];
                }
                if (properties.ContainsKey(this.ChannelName))
                {
                    this.channel_ = (string)properties["channelName"];
                }
                if (properties.ContainsKey(this.QueueManagerName))
                {
                    this.qmgrName_ = (string)properties["queueManagerName"];
                }
                if (properties.ContainsKey(this.SecurityExit))
                {
                    this.secExit = (string)properties["securityExit"];
                }
                if (properties.ContainsKey(this.SecurityExitUserData))
                {
                    this.secudata = (string)properties["securityExitUserData"];
                }
                if (properties.ContainsKey(this.UserId))
                {
                    this.userId = (string)properties["userId"];
                }
                if (properties.ContainsKey(this.UserMode))
                {
                    userMode = (bool)properties["UserMode"];
                }
                this.gmoB              = new MQGetMessageOptions();
                this.gmoG              = new MQGetMessageOptions();
                this.gmoB.Options      = 0x2021;
                this.gmoG.Options      = 3;
                this.gmoG.MatchOptions = 1;
                this.gmoG.WaitInterval = 0x7d0;
                this.gmoB.WaitInterval = 0x7d0;
                this.mqmd              = new MQMessageDescriptor();
                this.openOpts          = 0x202a;
                properties.Clear();
                this.properties.Add("channel", this.channel_);
                this.properties.Add("connectionName", this.connname_);
                this.properties.Add("transport", "MQSeries Managed Client");
                if (this.secExit != null)
                {
                    properties.Add("securityExit", this.secExit);
                }
                if (this.userId != null)
                {
                    properties.Add("userID", this.userId);
                }
                if (this.secudata != null)
                {
                    properties.Add("securityExitUserData", this.secudata);
                }
                this.InitiateForRecovery();
            }
            finally
            {
                log.WriteLog("WMQ .NET XA Recovery Monitor completed recovering transactions");
                base.TrExit(method);
            }
        }
Esempio n. 7
0
        public static byte[] GetMessage(NmqiEnvironment env, NmqiSP sp, Hconn hconn, Hobj hobj, MQMessageDescriptor md, MQGetMessageOptions gmo, int expectedMsgLength, int maxMsgLength, byte[] buffer, int msgTooSmallForBufferCount, out int dataLength, out int compCode, out int reason)
        {
            int num  = 0x1000;
            int num2 = 10;
            int num3 = (expectedMsgLength < 0) ? num : expectedMsgLength;

            num3 = Math.Min(num3, maxMsgLength);
            if ((buffer == null) || (buffer.Length < num3))
            {
                buffer = new byte[num3];
            }
            int encoding = md.Encoding;
            int ccsid    = md.Ccsid;

            byte[] msgId            = md.MsgId;
            byte[] correlId         = md.CorrelId;
            int    options          = gmo.Options;
            bool   callExitOnLenErr = false;
            int    returnedLength   = 0;
            int    bufferLength     = 0;

            byte[] buffer4 = null;
            dataLength = 0;
            compCode   = 0;
            reason     = 0;
            int num10 = 1;

            while (num10 != 0)
            {
                int num12;
                switch (num10)
                {
                case 1:
                    bufferLength = Math.Min(buffer.Length, maxMsgLength);
                    sp.NmqiGetMessage(hconn, hobj, md, gmo, bufferLength, buffer, out dataLength, out compCode, out reason);
                    num12 = reason;
                    if (num12 > 0x7da)
                    {
                        break;
                    }
                    switch (num12)
                    {
                    case 0:
                        goto Label_0100;

                    case 0x7da:
                        goto Label_0108;
                    }
                    goto Label_01CC;

                case 2:
                {
                    byte[] source    = buffer;
                    byte[] structure = new byte[bufferLength];
                    IntPtr zero      = IntPtr.Zero;
                    Marshal.StructureToPtr(structure, zero, false);
                    Marshal.Copy(source, 0, zero, dataLength);
                    buffer = structure;
                    int availableLength = dataLength;
                    if (!sp.NmqiConvertMessage(hconn, hobj, encoding, ccsid, options, callExitOnLenErr, md, buffer, out dataLength, availableLength, bufferLength, out compCode, out reason, out returnedLength))
                    {
                        goto Label_0232;
                    }
                    num10 = 0;
                    continue;
                }

                default:
                {
                    continue;
                }
                }
                switch (num12)
                {
                case 0x820:
                {
                    msgTooSmallForBufferCount = 0;
                    if (dataLength >= maxMsgLength)
                    {
                        goto Label_019C;
                    }
                    if (bufferLength < dataLength)
                    {
                        bufferLength = Math.Min(dataLength, maxMsgLength);
                    }
                    else
                    {
                        bufferLength = Math.Min(bufferLength * 2, maxMsgLength);
                    }
                    buffer4     = new byte[bufferLength];
                    buffer      = buffer4;
                    md.Encoding = encoding;
                    md.Ccsid    = ccsid;
                    md.MsgId    = msgId;
                    md.CorrelId = correlId;
                    num10       = 1;
                    continue;
                }

                case 0x848:
                case 0x88e:
                {
                    msgTooSmallForBufferCount = 0;
                    if (dataLength < maxMsgLength)
                    {
                        bufferLength = Math.Min(dataLength * 2, maxMsgLength);
                        num10        = 2;
                    }
                    else
                    {
                        num10 = 0;
                    }
                    continue;
                }

                default:
                    goto Label_01CC;
                }
Label_0100:
                num10 = 0;
                continue;
Label_0108:
                maxMsgLength = dataLength;
                md.Encoding  = encoding;
                md.Ccsid     = ccsid;
                md.MsgId     = msgId;
                md.CorrelId  = correlId;
                num10        = 1;
                continue;
Label_019C:
                num10 = 0;
                continue;
Label_01CC:
                num10 = 0;
                continue;
Label_0232:
                switch (reason)
                {
                case 0:
                {
                    num10 = 0;
                    continue;
                }

                case 0x848:
                case 0x88e:
                {
                    if (dataLength < maxMsgLength)
                    {
                        bufferLength = Math.Min(bufferLength * 2, maxMsgLength);
                        num10        = 2;
                    }
                    else
                    {
                        num10 = 0;
                    }
                    continue;
                }
                }
                num10 = 0;
            }
            byte[] buffer7 = buffer;
            if ((compCode == 0) || (compCode == 1))
            {
                if ((bufferLength > (dataLength * 2)) && (bufferLength > num))
                {
                    msgTooSmallForBufferCount++;
                }
                else
                {
                    msgTooSmallForBufferCount = 0;
                }
                if (msgTooSmallForBufferCount > num2)
                {
                    buffer = null;
                    msgTooSmallForBufferCount = 0;
                }
            }
            return(buffer7);
        }
Esempio n. 8
0
        private void LoadMessageAttribute(DumpReader reader, MQMessageDescriptor md)
        {
            if (reader.Line.Length < 5)
            {
                throw new DumpException($"Invalid attribute line on line {reader.LineNo}");
            }

            var code = reader.Line.Substring(2, 3);

            switch (code)
            {
            case "VER":
            case "RPT":
            case "MST":
            case "EXP":
            case "FDB":
            case "ENC":
            case "CCS":
            case "FMT":
            case "PRI":
            case "PER":
            case "MSI":
            case "COI":
            case "BOC":
            case "RTQ":
            case "RTM":
            case "USR":
            case "ACC":
            case "AID":
            case "AIX":
            case "PAT":
            case "PAN":
            case "PTD":
            case "PTT":
            case "AOD":
            case "AOX":
            case "GRP":
            case "MSQ":
            case "OFF":
            case "MSF":
            case "ORL":
                break;

            default:
                throw new DumpException($"Unrecognised attribute on line {reader.LineNo}");
            }

            if (reader.Line.Length < 7)
            {
                return;
            }


            var data = reader.Line.Substring(6);

            try
            {
                switch (code)
                {
                case "VER":
                    var ver = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Version = ver;
                    }
                    break;

                case "RPT":
                    var rpt = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Report = rpt;
                    }
                    break;

                case "MST":
                    var mst = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.MsgType = mst;
                    }
                    break;

                case "EXP":
                    var exp = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Expiry = exp;
                    }
                    break;

                case "FDB":
                    var fdb = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Feedback = fdb;
                    }
                    break;

                case "ENC":
                    var enc = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Encoding = enc;
                    }
                    break;

                case "CCS":
                    var v = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Ccsid = v;
                    }
                    break;

                case "FMT":
                    var format = md != null ? md.Format : new byte[8];
                    data.ToBytes(ref format, _encoding);
                    if (md != null)
                    {
                        md.Format = format;
                    }
                    break;

                case "PRI":
                    var pri = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Priority = pri;
                    }
                    break;

                case "PER":
                    var per = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Persistence = per;
                    }
                    break;

                case "MSI":
                    var msi = data.HexStringToBytes();
                    if (md != null)
                    {
                        md.MsgId = msi;
                    }
                    break;

                case "COI":
                    var coi = data.HexStringToBytes();
                    if (md != null)
                    {
                        md.CorrelId = coi;
                    }
                    break;

                case "BOC":
                    var boc = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.BackoutCount = boc;
                    }
                    break;

                case "RTQ":
                    var rtq = md != null ? md.ReplyToQueue : new byte[48];
                    data.ToBytes(ref rtq, _encoding);
                    if (md != null)
                    {
                        md.ReplyToQueue = rtq;
                    }
                    break;

                case "RTM":
                    var rtm = md != null ? md.ReplyToQueue : new byte[48];
                    data.ToBytes(ref rtm, _encoding);
                    if (md != null)
                    {
                        md.ReplyToQueueMgr = rtm;
                    }
                    break;

                case "USR":
                    var usr = md != null ? md.UserID : new byte[12];
                    data.ToBytes(ref usr, _encoding);
                    if (md != null)
                    {
                        md.UserID = usr;
                    }
                    break;

                case "ACC":
                    var acc = data.HexStringToBytes();
                    if (md != null)
                    {
                        md.AccountingToken = acc;
                    }
                    break;

                case "AID":
                    var aid = md != null ? md.ApplIdentityData : new byte[3];
                    data.ToBytes(ref aid, _encoding);
                    if (md != null)
                    {
                        md.ApplIdentityData = aid;
                    }
                    break;

                case "AIX":
                    var aix = data.HexStringToBytes();
                    if (md != null)
                    {
                        md.ApplIdentityData = aix;
                    }
                    break;

                case "PAT":
                    var pat = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.PutApplType = pat;
                    }
                    break;

                case "PAN":
                    var pan = md != null ? md.PutApplName : new byte[28];
                    data.ToBytes(ref pan, _encoding);
                    if (md != null)
                    {
                        md.PutApplName = pan;
                    }
                    break;

                case "PTD":
                    var ptd = md != null ? md.PutDate : new byte[8];
                    data.ToBytes(ref ptd, _encoding);
                    if (md != null)
                    {
                        md.PutDate = ptd;
                    }
                    break;

                case "PTT":
                    var ptt = md != null ? md.PutTime : new byte[8];
                    data.ToBytes(ref ptt, _encoding);
                    if (md != null)
                    {
                        md.PutTime = ptt;
                    }
                    break;

                case "AOD":
                    var aod = md != null ? md.ApplOriginData : new byte[4];
                    data.ToBytes(ref aod, _encoding);
                    if (md != null)
                    {
                        md.ApplOriginData = aod;
                    }
                    break;

                case "AOX":
                    var aox = data.HexStringToBytes();
                    if (md != null)
                    {
                        md.ApplOriginData = aox;
                    }
                    break;

                case "GRP":
                    var grp = data.HexStringToBytes();
                    if (md != null)
                    {
                        md.GroupID = grp;
                    }
                    break;

                case "MSQ":
                    var msq = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.MsgSequenceNumber = msq;
                    }
                    break;

                case "OFF":
                    var off = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.Offset = off;
                    }
                    break;

                case "MSF":
                    var msf = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.MsgFlags = msf;
                    }
                    break;

                case "ORL":
                    var orl = int.Parse(data, _culture);
                    if (md != null)
                    {
                        md.OriginalLength = orl;
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                throw new DumpException($"Invalid message attribute value on line {reader.LineNo}", ex);
            }
        }
Esempio n. 9
0
        private bool ReadFileMessage(DumpReader reader, out MQMessage msg, bool simulate = false)
        {
            msg = null;

            if (!reader.ReadLine(false, false))
            {
                return(false);
            }

            if (reader.Line[0] != 'A' && reader.Line[0] != 'N')
            {
                throw new DumpException($"Expected message attribute at line {reader.LineNo}");
            }

            if (reader.Line[0] == 'N')
            {
                if (!reader.ReadLine(true, false))
                {
                    throw new DumpException("Invalid end of file. Expected message data");
                }
            }

            MQMessageDescriptor md = null;

            if (!simulate)
            {
                msg = new MQMessage();
                md  = msg.GetDescriptor();
            }

            while (reader.Line[0] == 'A')
            {
                LoadMessageAttribute(reader, md);

                if (!reader.ReadLine(true, false))
                {
                    throw new DumpException("Invalid end of file. Expected message data");
                }
            }

            if (reader.Line[0] != 'X' && reader.Line[0] != 'T' && reader.Line[0] != 'S')
            {
                throw new DumpException($"Expected message at line {reader.LineNo}");
            }

            while (reader.Line[0] == 'X' || reader.Line[0] == 'T' || reader.Line[0] == 'S')
            {
                int skip = 1;
                if (reader.Line[0] == 'T')
                {
                    skip += 1;
                }
                else
                {
                    while (skip < reader.Line.Length && reader.Line[skip] == ' ')
                    {
                        skip += 1;
                    }
                }

                if (skip < reader.Line.Length)
                {
                    switch (reader.Line[0])
                    {
                    case 'X':
                        ReadMessageHex(reader, skip, msg);
                        break;

                    case 'S':
                        ReadMessageLine(reader, skip, msg);
                        break;

                    case 'T':
                        ReadMessageTextLine(reader, skip, msg);
                        break;
                    }
                }

                if (!reader.ReadLine(true, false))
                {
                    break;
                }
            }

            return(true);
        }
Esempio n. 10
0
        public bool Reconnect(ManagedHconn remoteHconn)
        {
            uint method = 0x4c3;

            this.TrEntry(method, new object[] { remoteHconn });
            int compCode = 0;
            int reason   = 0;

            try
            {
                Phconn pHconn = base.env.NewPhconn();
                remoteHconn.UnsetStarted();
                remoteHconn.GlobalMessageIndex = 0;
                base.TrText(method, string.Concat(new object[] { "Hconn : ", remoteHconn.Value, " ReconnectionID : ", remoteHconn.ConnectionId }));
                remoteHconn.NmqiConnectionOptions.ReconnectionID = remoteHconn.ConnectionId;
                try
                {
                    remoteHconn.DriveEventsEH(0, 0x9f0);
                }
                catch (Exception exception)
                {
                    base.TrException(method, exception);
                }
                try
                {
                    if (remoteHconn.NmqiConnectionOptions.RemoteQmidAsString == null)
                    {
                        remoteHconn.NmqiConnectionOptions.RemoteQmidAsString = remoteHconn.Uid;
                    }
                    base.TrText(method, string.Concat(new object[] { "Hconn : ", remoteHconn.Value, " RemoteQmidAsString : ", remoteHconn.NmqiConnectionOptions.RemoteQmidAsString }));
                }
                catch (NmqiException exception2)
                {
                    base.TrException(method, exception2, 1);
                    remoteHconn.SetReconnectionFailure(2, 0x9f4, exception2);
                    return(false);
                }
                string name = null;
                try
                {
                    name = remoteHconn.OriginalQueueManagerName;
                    base.TrText(method, string.Concat(new object[] { "Hconn : ", remoteHconn.Value, " OriginalQueueManagerName : ", name }));
                }
                catch (NmqiException exception3)
                {
                    base.TrException(method, exception3, 2);
                }
                MQFAP getMQFAP = remoteHconn.GetMQFAP;
                try
                {
                    getMQFAP.NmqiConnect(name, remoteHconn.NmqiConnectionOptions, remoteHconn.ConnectionOptions, remoteHconn.Parent, pHconn, out compCode, out reason, remoteHconn);
                    base.TrText(method, string.Concat(new object[] { "NmqiConnect during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (compCode != 0)
                    {
                        return(false);
                    }
                }
                catch (MQException exception4)
                {
                    base.TrException(method, exception4, 3);
                    if ((exception4.CompCode != 0) && (exception4.Reason == 0x9f2))
                    {
                        remoteHconn.SetReconnectionFailure(2, 0x9f2, null);
                    }
                    return(false);
                }
                catch (Exception exception5)
                {
                    base.TrException(method, exception5, 4);
                    return(false);
                }
                if (remoteHconn.InTransaction())
                {
                    remoteHconn.SetTransactionDoomed();
                }
                remoteHconn.UnSetQuiescing();
                foreach (ManagedHobj hobj in remoteHconn.Hobjs)
                {
                    if (hobj.ParentHsub == null)
                    {
                        Phobj manHobj              = base.env.NewPhobj();
                        MQObjectDescriptor mqod    = hobj.Mqod;
                        Hobj           hOBJ        = manHobj.HOBJ;
                        SpiOpenOptions spiOpenOpts = hobj.SpiOpenOpts;
                        base.TrText(method, "Reopening " + mqod.ObjectName);
                        base.TrText(method, "Original name " + hobj.OriginalObjectName);
                        getMQFAP.nmqiOpen(remoteHconn, ref mqod, ref spiOpenOpts, hobj.OpenOptions, ref manHobj, out compCode, out reason, hobj.SpiCall, hobj);
                        base.TrText(method, string.Concat(new object[] { "MQOPEN during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                        if (((reason == 0x825) || (reason == 0x827)) && !hobj.OriginalObjectName.Equals(mqod.ObjectName))
                        {
                            string objectName   = mqod.ObjectName;
                            string dynamicQName = mqod.DynamicQName;
                            compCode          = 0;
                            reason            = 0;
                            mqod.ObjectName   = hobj.OriginalObjectName;
                            mqod.DynamicQName = objectName;
                            getMQFAP.MQOPEN(remoteHconn, ref mqod, hobj.OpenOptions, manHobj, out compCode, out reason, hobj);
                            base.TrText(method, string.Concat(new object[] { "MQOPEN during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                            mqod.ObjectName   = objectName;
                            mqod.DynamicQName = dynamicQName;
                        }
                        if (reason != 0)
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                            return(false);
                        }
                        if (hobj.IsCallbackRegistered)
                        {
                            int operationP = 0x100;
                            if (hobj.IsCallbackSuspended)
                            {
                                operationP |= 0x10000;
                            }
                            MQCBD callbackDescriptor = hobj.CallbackDescriptor;
                            Hobj  hobjP = hobj;
                            MQMessageDescriptor callbackMessageDescriptor = hobj.CallbackMessageDescriptor;
                            MQGetMessageOptions callbackGetMessageOptions = hobj.CallbackGetMessageOptions;
                            getMQFAP.MQCB(remoteHconn, operationP, callbackDescriptor, hobjP, callbackMessageDescriptor, callbackGetMessageOptions, out compCode, out reason);
                            base.TrText(method, string.Concat(new object[] { "MQCB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                            if (reason != 0)
                            {
                                remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                                return(false);
                            }
                        }
                    }
                }
                foreach (ManagedHsub hsub in remoteHconn.Hsbjs)
                {
                    int options = hsub.Mqsd.Options;
                    if ((options & 1) != 0)
                    {
                        options |= 2;
                    }
                    if ((options & 0x20) == 0)
                    {
                        options |= 0x400000;
                    }
                    if (((options & 8) != 0) && ((options & 6) != 0))
                    {
                        options |= 6;
                    }
                    hsub.Mqsd.Options = options;
                    Phobj pHsub = base.env.NewPhobj();
                    Phobj pHobj = base.env.NewPhobj();
                    if (hsub.Mqsd.SubExpiry != -1)
                    {
                        hsub.Mqsd.SubExpiry = hsub.GeExpiryRemainder();
                    }
                    getMQFAP.nmqiSubscribe(remoteHconn, hsub.Mqsd, ref pHobj, ref pHsub, out compCode, out reason, hsub.SpiSD, hsub.SpiCall, hsub);
                    base.TrText(method, string.Concat(new object[] { "MQSUB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (reason != 0)
                    {
                        if (!ManagedHconn.IsReconnectableReasonCode(reason) && (reason != 0x97d))
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                        }
                        return(false);
                    }
                    ManagedHobj hobj3 = hsub.Hobj;
                    if (((hobj3 != null) && (hobj3.ProxyQueue != null)) && hobj3.IsCallbackRegistered)
                    {
                        int num6 = 0x100;
                        if (hobj3.IsCallbackSuspended)
                        {
                            num6 |= 0x10000;
                        }
                        MQCBD pCallbackDesc             = hobj3.CallbackDescriptor;
                        Hobj  hobj4                     = hobj3;
                        MQMessageDescriptor pMsgDescP   = hobj3.CallbackMessageDescriptor;
                        MQGetMessageOptions getMsgOptsP = hobj3.CallbackGetMessageOptions;
                        getMQFAP.MQCB(remoteHconn, num6, pCallbackDesc, hobj4, pMsgDescP, getMsgOptsP, out compCode, out reason);
                        base.TrText(method, string.Concat(new object[] { "MQCB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                        if (reason != 0)
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                            return(false);
                        }
                    }
                }
                if (remoteHconn.IsEventRegistered)
                {
                    int num7 = 0x100;
                    if (remoteHconn.IsEventSuspended)
                    {
                        num7 |= 0x10000;
                    }
                    getMQFAP.MQCB(remoteHconn, num7, remoteHconn.GetEventDescriptor(), base.env.NewPhobj().HOBJ, null, null, out compCode, out reason);
                    base.TrText(method, string.Concat(new object[] { "MQCB during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (reason != 0)
                    {
                        if (!ManagedHconn.IsReconnectableReasonCode(reason))
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                        }
                        return(false);
                    }
                }
                if (remoteHconn.IsCallbackStarted())
                {
                    MQCTLO pControlOpts = base.env.NewMQCTLO();
                    getMQFAP.MQCTL(remoteHconn, 1, pControlOpts, out compCode, out reason);
                    base.TrText(method, string.Concat(new object[] { "MQCTL during reconnect completed with CompCode = ", compCode, " Reason = ", reason }));
                    if (reason != 0)
                    {
                        if (!ManagedHconn.IsReconnectableReasonCode(reason))
                        {
                            remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                        }
                        return(false);
                    }
                    if (remoteHconn.IsCallbackSuspended())
                    {
                        getMQFAP.MQCTL(remoteHconn, 0x10000, pControlOpts, out compCode, out reason);
                        if (reason != 0)
                        {
                            if (!ManagedHconn.IsReconnectableReasonCode(reason))
                            {
                                remoteHconn.SetReconnectionFailure(2, 0x9f4, new NmqiException(base.env, -1, null, compCode, reason, null));
                            }
                            return(false);
                        }
                    }
                    remoteHconn.WakeDispatchThread();
                }
            }
            finally
            {
                base.TrExit(method, true, 11);
            }
            return(true);
        }
Esempio n. 11
0
        private void LoadMessageAttribute(string line, MQMessageDescriptor md)
        {
            var code = line.Substring(2, 3);
            var data = line.Substring(6);

            //var md = GetDescriptor(msg);

            switch (code)
            {
            case "VER":
                md.Version = int.Parse(data, _culture);
                break;

            case "RPT":
                md.Report = int.Parse(data, _culture);
                break;

            case "MST":
                md.MsgType = int.Parse(data, _culture);
                break;

            case "EXP":
                md.Expiry = int.Parse(data, _culture);
                break;

            case "FDB":
                md.Feedback = int.Parse(data, _culture);
                break;

            case "ENC":
                md.Encoding = int.Parse(data, _culture);
                break;

            case "CCS":
                md.Ccsid = int.Parse(data, _culture);
                break;

            case "FMT":
                var format = md.Format;
                data.ToBytes(ref format, _encoding);
                md.Format = format;
                break;

            case "PRI":
                md.Priority = int.Parse(data, _culture);
                break;

            case "PER":
                md.Persistence = int.Parse(data, _culture);
                break;

            case "MSI":
                md.MsgId = data.HexStringToBytes();
                break;

            case "COI":
                md.CorrelId = data.HexStringToBytes();
                break;

            case "BOC":
                md.BackoutCount = int.Parse(data, _culture);
                break;

            case "RTQ":
                var rtq = md.ReplyToQueue;
                data.ToBytes(ref rtq, _encoding);
                md.ReplyToQueue = rtq;
                break;

            case "RTM":
                var rtm = md.ReplyToQueue;
                data.ToBytes(ref rtm, _encoding);
                md.ReplyToQueueMgr = rtm;
                break;

            case "USR":
                var usr = md.UserID;
                data.ToBytes(ref usr, _encoding);
                md.UserID = usr;
                break;

            case "ACC":
                md.AccountingToken = data.HexStringToBytes();
                break;

            case "AIX":
                md.ApplIdentityData = data.HexStringToBytes();
                break;

            case "PAT":
                md.PutApplType = int.Parse(data, _culture);
                break;

            case "PAN":
                var pan = md.PutApplName;
                data.ToBytes(ref pan, _encoding);
                md.PutApplName = pan;
                break;

            case "PTD":
                var ptd = md.PutDate;
                data.ToBytes(ref ptd, _encoding);
                md.PutDate = ptd;
                break;

            case "PTT":
                var ptt = md.PutTime;
                data.ToBytes(ref ptt, _encoding);
                md.PutTime = ptt;
                break;

            case "AOX":
                md.ApplOriginData = data.HexStringToBytes();
                break;

            case "GRP":
                md.GroupID = data.HexStringToBytes();
                break;

            case "MSQ":
                md.MsgSequenceNumber = int.Parse(data, _culture);
                break;

            case "OFF":
                md.Offset = int.Parse(data, _culture);
                break;

            case "MSF":
                md.MsgFlags = int.Parse(data, _culture);
                break;

            case "ORL":
                md.OriginalLength = int.Parse(data, _culture);
                break;
            }
        }
Esempio n. 12
0
        public int LoadDump(DumpLoadSettings settings, CancellationToken ct, IProgress <int> progress = null)
        {
            MQQueue ibmQ = null;

            var mqPutMsgOpts = new MQPutMessageOptions {
                Options = MQC.MQPMO_FAIL_IF_QUIESCING | MQC.MQPMO_ASYNC_RESPONSE
            };

            if (settings.UseTransaction)
            {
                mqPutMsgOpts.Options |= MQC.MQPMO_SYNCPOINT;
            }
            else
            {
                mqPutMsgOpts.Options |= MQC.MQPMO_NO_SYNCPOINT;
            }

            switch (settings.Context)
            {
            case DumpLoadSettings.ContextMode.SetAll:
                mqPutMsgOpts.Options |= MQC.MQPMO_SET_ALL_CONTEXT;
                break;

            case DumpLoadSettings.ContextMode.SetIdentity:
                mqPutMsgOpts.Options |= MQC.MQPMO_SET_IDENTITY_CONTEXT;
                break;

            case DumpLoadSettings.ContextMode.NoContext:
                mqPutMsgOpts.Options |= MQC.MQPMO_NO_CONTEXT;
                break;

            case DumpLoadSettings.ContextMode.Default:
                break;
            }

            try
            {
                ibmQ = _qSource.NewConnectionCore().OpenQueueCore(OpenQueueMode.ForWrite);
                using (var sr = File.OpenText(settings.FileName))
                {
                    MQMessage           msg = null;
                    MQMessageDescriptor md  = null;

                    var counter = 0;

                    while (!sr.EndOfStream)
                    {
                        var line = sr.ReadLine();

                        if (string.IsNullOrEmpty(line)) // a blank line between each message
                        {
                            if (msg != null)
                            {
                                if (progress != null && ct.IsCancellationRequested)
                                {
                                    break;
                                }

                                ibmQ.Put(msg, mqPutMsgOpts);
                                counter++;

                                if (counter % 100 == 0)
                                {
                                    progress?.Report(counter);
                                }
                            }
                            msg = new MQMessage();
                            md  = GetDescriptor(msg);
                        }
                        else
                        {
                            switch (line[0])
                            {
                            case 'A':
                                LoadMessageAttribute(line, md);
                                break;

                            case 'X':
                                LoadMessageContent(line, msg);
                                break;
                            }
                        }
                    }
                    progress?.Report(counter);
                    return(counter);
                }
            }
            catch (MQException ibmEx)
            {
                throw ibmEx.ToMqException(AddExtraInfoToError);
            }
            finally
            {
                ibmQ?.Close();
            }
        }