public void Stop() { if (started.CompareAndSet(true, false)) { try { qpidReceiver.Dispose(); qpidReceiver = null; } catch (Org.Apache.Qpid.Messaging.QpidException e) { throw new NMSException("Failed to close session with Id " + ConsumerId.ToString() + " : " + e.Message); } } }
public void Start() { // Don't try creating receiver if session not yet up if (!session.IsStarted) { throw new SessionClosedException(); } if (started.CompareAndSet(false, true)) { try { // Create qpid receiver Tracer.DebugFormat("Start Consumer Id = " + ConsumerId.ToString()); if (qpidReceiver == null) { qpidReceiver = session.CreateQpidReceiver(destination.Address); // Recover replyTo address from qpid receiver and set as the // replyTo destination for received messages. Address replyTo = qpidReceiver.GetAddress(); if (destination.IsQueue) { Queue queue = new Queue(replyTo.Name, replyTo.Subject, replyTo.Options); replyToDestination = (Destination)queue; } else if (destination.IsTopic) { Topic topic = new Topic(replyTo.Name, replyTo.Subject, replyTo.Options); replyToDestination = (Destination)topic; } } } catch (Org.Apache.Qpid.Messaging.QpidException e) { throw new NMSException("Failed to create Qpid Receiver : " + e.Message); } } }