Apache.NMS.ActiveMQ.Session.Close C# (CSharp) Method

Close() public method

public Close ( ) : void
return void
        public void Close()
        {
            lock(myLock)
            {
                if(this.closed)
                {
                    return;
                }

                try
                {
                    if(transactionContext.InNetTransaction)
                    {
                        this.transactionContext.AddSynchronization(new SessionCloseSynchronization(this));
                    }
                    else
                    {
                        Tracer.InfoFormat("Closing The Session with Id {0}", this.info.SessionId.ToString());
                        DoClose();
                        Tracer.InfoFormat("Closed The Session with Id {0}", this.info.SessionId.ToString());
                    }
                }
                catch(Exception ex)
                {
                    Tracer.ErrorFormat("Error during session close: {0}", ex);
                }
            }
        }

Usage Example

Example #1
0
 internal void OnSessionException(Session sender, Exception exception)
 {
     if(ExceptionListener != null)
     {
         try
         {
             ExceptionListener(exception);
         }
         catch
         {
             sender.Close();
         }
     }
 }