private bool TryMQ(SqlMessageQueue sqlmq, out MessageQueue mq) { mq = null; if (sqlmq != null && _messageQueueNum > 0) { int index = 0; if (sqlmq.IdentityID > 0) { index = sqlmq.IdentityID % _messageQueueNum; } if (mqList.Count > 0 && index < mqList.Count) { mq = mqList[index]; return true; } } return false; }
/// <summary> /// /// </summary> /// <param name="identityID">标识ID</param> /// <param name="providerType">数据驱动连接提供者类型</param> /// <param name="connectingStr"></param> /// <param name="aCommandType"></param> /// <param name="aCommandText"></param> /// <param name="aParamters"></param> public void SendSqlCmd(int identityID, string providerType, string connectingStr, CommandType aCommandType, String aCommandText, DbParameter[] aParamters) { try { if (System.Threading.Monitor.TryEnter(SourceText.StLockMsmq, 3000)) { try { this.msmqCmd = MSMQCmd.SendSQLCmd; this.oSqlMessageQueue = new SqlMessageQueue(); this.oSqlMessageQueue.CreateBody(identityID, providerType, connectingStr, aCommandType, aCommandText, aParamters); this.SendMessage(MSMQCmd.SendSQLCmd, this.oSqlMessageQueue); } finally { System.Threading.Monitor.Exit(SourceText.StLockMsmq); } } else { throw new Exception("SendTimeOut"); } } catch (Exception ex) { BaseLog baselog = new BaseLog("ActionMsmq"); baselog.SaveLog(aCommandText, ex); } }