public ISession CreateSession(AcknowledgementMode acknowledgementMode)
        {
            CheckClosedOrFailed();
            CreateNmsConnection();

            NmsSession session = new NmsSession(this, SessionIdGenerator.GenerateId(), acknowledgementMode)
            {
                SessionInfo = { requestTimeout = ConnectionInfo.requestTimeout }
            };

            try
            {
                session.Begin().ConfigureAwait(false).GetAwaiter().GetResult();
                sessions.TryAdd(session.SessionInfo.Id, session);
                if (started)
                {
                    session.Start();
                }

                return(session);
            }
            catch (NMSException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionSupport.Wrap(ex, "Failed to establish amqp Session.");
            }
        }
        /// <summary>
        /// Creates session from given user name
        /// </summary>
        /// <param name="userName"></param>
        /// <returns>String representing id of created session</returns>
        public string CreateSession(string userName)
        {
            var user    = DAL.Instance.Users.First(user2 => user2.UserName == userName);
            var session = new Session(_sessionIdGenerator.GenerateId(), user.Id);

            DAL.Instance.Sessions.Add(session);
            user.Sessions.Add(session.Id);
            DAL.Instance.Users.Update(user);

            return(session.SessionId);
        }