public void Dispose() { lock (this) { this.producer.Dispose(); this.producer = null; if (this.isInitializedForSynchronous) { this.responseBuffer.Clear(); this.responseBuffer = null; this.responseConsumer.Dispose(); this.responseConsumer = null; } this.connection.ConnectionInterrupted -= new EventHandler<NmsConnectionEventArgs>(connection_ConnectionInterrupted); this.connection.ConnectionResumed -= new EventHandler<NmsConnectionEventArgs>(connection_ConnectionResumed); this.session.Dispose(); this.session = null; this.messageFactory = null; this.connection = null; this.destination = null; this.asr.Close(); this.asr = null; } }
private void Setup(INmsConnection connection, MsgDeliveryMode deliveryMode, bool synchronous) { this.isSynchronous = synchronous; this.deliveryMode = deliveryMode; this.connection = connection; this.session = connection.GetSession(); this.messageFactory = new MessageFactory(this.session.InnerSession); this.connection.ConnectionInterrupted += new EventHandler<NmsConnectionEventArgs>(connection_ConnectionInterrupted); this.connection.ConnectionResumed += new EventHandler<NmsConnectionEventArgs>(connection_ConnectionResumed); if (this.innerDestination == null) { this.producer = this.session.CreateProducer(); } else { this.destination = this.innerDestination.GetDestination(this.session); this.producer = this.session.CreateProducer(this.destination); } this.producer.DeliveryMode = deliveryMode; if (synchronous) this.InitializeForSynchronous(); this.isInitialized = true; this.asr.Set(); }