Beispiel #1
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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Посыл
        /// </summary>
        public void Send(MqMessageGeneric MqMessage)
        {
            String qname = this.queueName;

            if (String.IsNullOrWhiteSpace(qname))
            {
                throw new ArgumentNullException("Не определено имя очереди");
            }

            try
            {
                message              = new MQMessage();
                message.Persistence  = MQC.MQPER_PERSISTENT;
                message.Format       = MQC.MQFMT_STRING;
                message.CharacterSet = MQC.CODESET_UTF;

                foreach (var prop in MqMessage.AddedProperties)
                {
                    message.SetStringProperty(prop.Key, prop.Value);
                }

                message.Write(Encoding.UTF8.GetBytes(MqMessage.Body));

                SendMqMessage(qname);
                MqMessage.MessageID = message.MessageId;
                message             = null;
            }
            catch (MQException mqex)
            {
                message = null;
                throw new InvalidOperationException(String.Format("MQ {0}", mqex.Message));
            }
            catch
            {
                throw;
            }
        }