RemoveSession() 개인적인 메소드

private RemoveSession ( Session session ) : void
session Session
리턴 void
예제 #1
0
        public void Close()
        {
            lock (this)
            {
                if (this.closed)
                {
                    return;
                }

                try
                {
                    StopAsyncDelivery();
                    Connection.RemoveSession(this);
                    foreach (MessageConsumer consumer in GetConsumers())
                    {
                        consumer.Close();
                    }
                    consumers.Clear();

                    foreach (MessageProducer producer in GetProducers())
                    {
                        producer.Close();
                    }
                    producers.Clear();
                }
                catch (Exception ex)
                {
                    Tracer.ErrorFormat("Error during session close: {0}", ex);
                }

                this.connection = null;
                this.closed     = true;
            }
        }
예제 #2
0
        public void Close()
        {
            lock (myLock)
            {
                if (this.closed)
                {
                    return;
                }

                try
                {
                    this.closing = true;
                    StopAsyncDelivery();
                    lock (consumers.SyncRoot)
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.Close();
                        }
                    }
                    consumers.Clear();

                    lock (producers.SyncRoot)
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.Close();
                        }
                    }
                    producers.Clear();
                    Connection.RemoveSession(this);
                }
                catch (Exception ex)
                {
                    Tracer.ErrorFormat("Error during session close: {0}", ex);
                }
                finally
                {
                    this.connection = null;
                    this.closed     = true;
                    this.closing    = false;
                }
            }
        }
예제 #3
0
        internal async Task ShutdownAsync()
        {
            Tracer.InfoFormat("Executing Shutdown on Session with Id {0}", this.info.SessionId);

            if (this.closed)
            {
                return;
            }

            using (await myLock.LockAsync().Await())
            {
                if (this.closed || this.closing)
                {
                    return;
                }

                try
                {
                    this.closing = true;

                    // Stop all message deliveries from this Session
                    this.executor.Stop(this.closeStopTimeout);

                    using (await consumersLock.LockAsync().Await())
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.FailureError = this.connection.FirstFailureError;
                            consumer.ShutdownAsync().GetAsyncResult();
                            this.lastDeliveredSequenceId =
                                Math.Max(this.lastDeliveredSequenceId, consumer.LastDeliveredSequenceId);
                        }
                        // tried to move here
                        consumers.Clear();
                    }


                    using (await producersLock.LockAsync().Await())
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.Shutdown();
                        }
                        producers.Clear();
                    }


                    // If in a local transaction we just roll back at this point.
                    if (this.IsTransacted && this.transactionContext.InLocalTransaction)
                    {
                        try
                        {
                            await this.transactionContext.RollbackAsync().Await();
                        }
                        catch
                        {
                        }
                    }

                    Connection.RemoveSession(this);
                }
                catch (Exception ex)
                {
                    Tracer.ErrorFormat("Error during session close: {0}", ex);
                }
                finally
                {
                    this.closed  = true;
                    this.closing = false;
                }
            }
        }
예제 #4
0
        internal void Shutdown()
        {
            Tracer.InfoFormat("Executing Shutdown on Session with Id {0}", this.info.SessionId);

            if (this.closed)
            {
                return;
            }

            lock (myLock)
            {
                if (this.closed || this.closing)
                {
                    return;
                }

                try
                {
                    this.closing = true;

                    // Stop all message deliveries from this Session
                    this.executor.Stop(this.closeStopTimeout);

                    lock (consumers.SyncRoot)
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.FailureError = this.connection.FirstFailureError;
                            consumer.Shutdown();
                            this.lastDeliveredSequenceId =
                                Math.Min(this.lastDeliveredSequenceId, consumer.LastDeliveredSequenceId);
                        }
                    }
                    consumers.Clear();

                    lock (producers.SyncRoot)
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.Shutdown();
                        }
                    }
                    producers.Clear();

                    // If in a local transaction we just roll back at this point.
                    if (this.IsTransacted && this.transactionContext.InLocalTransaction)
                    {
                        try
                        {
                            this.transactionContext.Rollback();
                        }
                        catch
                        {
                        }
                    }

                    Connection.RemoveSession(this);
                }
                catch (Exception ex)
                {
                    Tracer.ErrorFormat("Error during session close: {0}", ex);
                }
                finally
                {
                    this.closed  = true;
                    this.closing = false;
                }
            }
        }
예제 #5
0
        internal void DoClose()
        {
            lock (myLock)
            {
                if (this.closed)
                {
                    return;
                }

                try
                {
                    this.closing = true;

                    // Stop all message deliveries from this Session
                    this.executor.Stop(this.closeStopTimeout);

                    lock (consumers.SyncRoot)
                    {
                        foreach (MessageConsumer consumer in consumers.Values)
                        {
                            consumer.DoClose();
                            this.lastDeliveredSequenceId =
                                Math.Min(this.lastDeliveredSequenceId, consumer.LastDeliveredSequenceId);
                        }
                    }
                    consumers.Clear();

                    lock (producers.SyncRoot)
                    {
                        foreach (MessageProducer producer in producers.Values)
                        {
                            producer.DoClose();
                        }
                    }
                    producers.Clear();

                    // If in a transaction roll it back
                    if (this.IsTransacted && this.transactionContext.InTransaction)
                    {
                        try
                        {
                            this.transactionContext.Rollback();
                        }
                        catch
                        {
                        }
                    }

                    Connection.RemoveSession(this);
                }
                catch (Exception ex)
                {
                    Tracer.ErrorFormat("Error during session close: {0}", ex);
                }
                finally
                {
                    this.closed  = true;
                    this.closing = false;
                }
            }
        }