예제 #1
0
        public void Release(ISession session)
        {
            if (Transaction.Current != null)
            {
                return;
            }

            pooledSessionFactory.Release(session);
        }
예제 #2
0
        public void Release(ISession session)
        {
            if (sessionsForThreads.ContainsKey(Thread.CurrentThread.ManagedThreadId))
            {
                return;
            }

            session.Commit();
            pooledSessionFactory.Release(session);
        }
예제 #3
0
 public void DisposeManaged()
 {
     if (sessionFactory != null)
     {
         sessionFactory.Release(session);
     }
     if (resetEvent != null)
     {
         resetEvent.Dispose();
     }
 }
예제 #4
0
        private void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                sessionFactory.Release(session);
            }

            disposed = true;
        }
예제 #5
0
파일: NetServer.cs 프로젝트: lanicon/EuNet
        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);
            }
        }
예제 #6
0
        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);
            }
        }