public void TestCreateFromSessionId() { var sessionInfo = new NmsSessionInfo(firstId); Assert.AreSame(firstId, sessionInfo.Id); Assert.IsFalse(string.IsNullOrEmpty(sessionInfo.ToString())); }
public async Task CreateSession(NmsSessionInfo sessionInfo) { var amqpSession = new AmqpSession(this, sessionInfo); await amqpSession.Start().ConfigureAwait(false); sessions.TryAdd(sessionInfo.Id, amqpSession); }
public void TestIsTransacted() { var sessionInfo = new NmsSessionInfo(firstId); sessionInfo.AcknowledgementMode = AcknowledgementMode.AutoAcknowledge; Assert.IsFalse(sessionInfo.IsTransacted); sessionInfo.AcknowledgementMode = AcknowledgementMode.Transactional; Assert.IsTrue(sessionInfo.IsTransacted); }
public AmqpSession(AmqpConnection connection, NmsSessionInfo sessionInfo) { Connection = connection; SessionInfo = sessionInfo; if (sessionInfo.IsTransacted) { TransactionContext = new AmqpTransactionContext(this); } }
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); }
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()); }
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); } }
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); }
public AmqpConnectionSession(AmqpConnection connection, NmsSessionInfo sessionInfo) : base(connection, sessionInfo) { this.hasClientId = connection.Info.IsExplicitClientId; }
public void TestCreateFromConnectionInfo() { var sessionInfo = new NmsSessionInfo(connectionInfo, 1); Assert.AreEqual(connectionInfo.Id, sessionInfo.Id.ConnectionId); }