public void Release(ISession session) { if (Transaction.Current != null) { return; } pooledSessionFactory.Release(session); }
public void Release(ISession session) { if (sessionsForThreads.ContainsKey(Thread.CurrentThread.ManagedThreadId)) { return; } session.Commit(); pooledSessionFactory.Release(session); }
public void DisposeManaged() { if (sessionFactory != null) { sessionFactory.Release(session); } if (resetEvent != null) { resetEvent.Dispose(); } }
private void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { sessionFactory.Release(session); } disposed = true; }
private async Task HandleSession(ServerSession session) { _sessionManager.InsertSession(session); try { _logger.LogInformation($"A new session connected: {session.SessionId}"); session.OnSessionConnected(); OnSessionConnected?.Invoke(session); try { await session.RunAsync(); } catch (Exception e) { _logger.LogError(e, $"Failed to handle the session {session.SessionId}."); session.Close(); } if (_udpSocket != null) { _udpSocket.RemoveSession(session); } _logger.LogInformation($"The session disconnected: {session.SessionId}"); OnSessionClosed?.Invoke(session); await session.OnSessionClosed(); } catch (Exception e) { _logger.LogError(e, $"Failed to handle the session {session.SessionId}."); } finally { _sessionManager.RemoveSession(session); _sessionFactory.Release(session); } }
public void SendMessage(TransportMessage message, string destination, string destinationPrefix) { var session = sessionFactory.GetSession(); try { var jmsMessage = activeMqMessageMapper.CreateJmsMessage(message, session); using (var producer = session.CreateProducer()) { producer.Send(destinationEvaluator.GetDestination(session, destination, destinationPrefix), jmsMessage); } // We assign here the Id to the underlying id which was chosen by the broker. // TODO: Why do we need this daniel/remo? //message.Id = jmsMessage.NMSMessageId; } finally { sessionFactory.Release(session); } }