コード例 #1
0
        public void TestCreateFromSessionId()
        {
            var sessionInfo = new NmsSessionInfo(firstId);

            Assert.AreSame(firstId, sessionInfo.Id);
            Assert.IsFalse(string.IsNullOrEmpty(sessionInfo.ToString()));
        }
コード例 #2
0
        public async Task CreateSession(NmsSessionInfo sessionInfo)
        {
            var amqpSession = new AmqpSession(this, sessionInfo);
            await amqpSession.Start().ConfigureAwait(false);

            sessions.TryAdd(sessionInfo.Id, amqpSession);
        }
コード例 #3
0
        public void TestIsTransacted()
        {
            var sessionInfo = new NmsSessionInfo(firstId);

            sessionInfo.AcknowledgementMode = AcknowledgementMode.AutoAcknowledge;
            Assert.IsFalse(sessionInfo.IsTransacted);
            sessionInfo.AcknowledgementMode = AcknowledgementMode.Transactional;
            Assert.IsTrue(sessionInfo.IsTransacted);
        }
コード例 #4
0
        public AmqpSession(AmqpConnection connection, NmsSessionInfo sessionInfo)
        {
            Connection  = connection;
            SessionInfo = sessionInfo;

            if (sessionInfo.IsTransacted)
            {
                TransactionContext = new AmqpTransactionContext(this);
            }
        }
コード例 #5
0
        public void TestEqualsCode()
        {
            var first  = new NmsSessionInfo(firstId);
            var second = new NmsSessionInfo(secondId);

            Assert.AreEqual(first, first);
            Assert.AreEqual(second, second);

            Assert.AreNotEqual(first, second);
        }
コード例 #6
0
        public void TestHashCode()
        {
            var first  = new NmsSessionInfo(firstId);
            var second = new NmsSessionInfo(secondId);

            Assert.AreEqual(first.GetHashCode(), first.GetHashCode());
            Assert.AreEqual(second.GetHashCode(), second.GetHashCode());

            Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
        }
コード例 #7
0
        public NmsSession(NmsConnection connection, NmsSessionId sessionId, AcknowledgementMode acknowledgementMode)
        {
            Connection = connection;
            this.acknowledgementMode = acknowledgementMode;
            SessionInfo = new NmsSessionInfo(sessionId)
            {
                AcknowledgementMode = acknowledgementMode
            };

            if (AcknowledgementMode == AcknowledgementMode.Transactional)
            {
                TransactionContext = new NmsLocalTransactionContext(this);
            }
            else
            {
                TransactionContext = new NmsNoTxTransactionContext(this);
            }
        }
コード例 #8
0
        internal async Task Start()
        {
            Address address = UriUtil.ToAddress(remoteUri, Info.UserName, Info.Password);

            this.tsc             = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously);
            underlyingConnection = await transport.CreateAsync(address, new AmqpHandler(this)).ConfigureAwait(false);

            underlyingConnection.AddClosedCallback(OnClosed);

            // Wait for connection to be opened
            await this.tsc.Task.ConfigureAwait(false);

            // Create a Session for this connection that is used for Temporary Destinations
            // and perhaps later on management and advisory monitoring.
            NmsSessionInfo sessionInfo = new NmsSessionInfo(Info, -1);

            sessionInfo.AcknowledgementMode = AcknowledgementMode.AutoAcknowledge;

            connectionSession = new AmqpConnectionSession(this, sessionInfo);
            await connectionSession.Start().ConfigureAwait(false);
        }
コード例 #9
0
 public AmqpConnectionSession(AmqpConnection connection, NmsSessionInfo sessionInfo) : base(connection, sessionInfo)
 {
     this.hasClientId = connection.Info.IsExplicitClientId;
 }
コード例 #10
0
        public void TestCreateFromConnectionInfo()
        {
            var sessionInfo = new NmsSessionInfo(connectionInfo, 1);

            Assert.AreEqual(connectionInfo.Id, sessionInfo.Id.ConnectionId);
        }