public void TestInit() { clientId = Guid.NewGuid().ToString(); this.sessionPersist = new MemoryPersist(username, sessionId, clientId); this.CallbackIsCalled = false; this.IsExpected = false; }
public BrokerQueue GetPersistQueueByClient(string clientId, string userName, out bool isNewCreate) { BrokerTracing.TraceInfo($"[GetPersistQueueByClient] username:{userName}, sessionid:{this.sessionId}, client:{clientId}"); isNewCreate = false; if (string.IsNullOrEmpty(clientId)) { clientId = BrokerQueueFactory.defaultClientId; } BrokerQueue brokerQueue = null; lock (this.clientBrokerQueueDic) { this.clientBrokerQueueDic.TryGetValue(clientId, out brokerQueue); } if (brokerQueue == null) { lock (this.thisLockObj) { lock (this.clientBrokerQueueDic) { this.clientBrokerQueueDic.TryGetValue(clientId, out brokerQueue); } if (brokerQueue == null) { ISessionPersist sessionPersist = null; if (string.IsNullOrEmpty(this.persistName)) { sessionPersist = new MemoryPersist(userName, this.sessionId, clientId); brokerQueue = new BrokerPersistQueue( this.brokerQueueDispatcher, this.persistName, this.sessionId, clientId, sessionPersist, 1, // no request cache // no request cache 1, // no response cache // no response cache 0, // no timeout // no timeout false, // no in-memory cache this.sharedData, this); this.brokerQueueDispatcher.AddBrokerQueue(brokerQueue, null); } else { ParamCheckUtility.ThrowIfNull(this.sharedData.BrokerInfo.AzureStorageConnectionString, "StorageConnectString"); sessionPersist = new AzureQueuePersist(userName, this.sessionId, clientId, this.sharedData.BrokerInfo.AzureStorageConnectionString); isNewCreate = sessionPersist.IsNewCreated; brokerQueue = new BrokerPersistQueue( this.brokerQueueDispatcher, this.persistName, this.sessionId, clientId, sessionPersist, BrokerQueueConstants.DefaultThresholdForRequestPersist, BrokerQueueConstants.DefaultThresholdForResponsePersist, BrokerQueueConstants.DefaultMessagesInCacheTimeout, isNewCreate, // need in-memory quick cache for newly-created durable queue // need in-memory quick cache for newly-created durable queue this.sharedData, this); // // For an existing durable queue, if EndOfMessage is not received, or there are requests waiting to be processed, // then schedule the broker queue for dispatching; // for an newly created durable queue, it will be added to brokerQueueDispatcher when BrokerQueuePersist.Flush // is called (with quick cache filled), so no need to call AddBrokerQueue here (bug #21453) // if (!isNewCreate && (!brokerQueue.EOMReceived || sessionPersist.RequestsCount > 0)) { this.brokerQueueDispatcher.AddBrokerQueue(brokerQueue, null); } } lock (this.clientBrokerQueueDic) { this.clientBrokerQueueDic.Add(clientId, brokerQueue); } } } } // Bug 6313: Check the user name ThrowIfUserNameDoesNotMatch(brokerQueue, userName); return(brokerQueue); }