/// <summary> /// Starts this message queue. /// </summary> public void Start() { try { if (_messageDeliveryThread != null) { return; } _wasStarted = false; RegisterAtAllMessageChannels(); _shutdownWatcher = ShutdownWatcher.Create(this); _terminatedEvent.Reset(); Thread thread; lock (_syncObj) _messageDeliveryThread = thread = new Thread(DoWork) { Name = string.Format("AMQ '{0}'", _queueName) }; thread.Start(); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error("Unhandled exception in start method of async message queue '{0}'", e, _queueName); } }
public static ShutdownWatcher Create(AsynchronousMessageQueue owner) { IMessageBroker broker = ServiceRegistration.Get<IMessageBroker>(); ShutdownWatcher result = new ShutdownWatcher(owner); broker.RegisterMessageReceiver(SystemMessaging.CHANNEL, result); return result; }
public static ShutdownWatcher Create(AsynchronousMessageQueue owner) { IMessageBroker broker = ServiceRegistration.Get <IMessageBroker>(); ShutdownWatcher result = new ShutdownWatcher(owner); broker.RegisterMessageReceiver(SystemMessaging.CHANNEL, result); return(result); }
/// <summary> /// Terminates this message queue. Once the queue is terminated, no further messages are delivered. /// But as this method runs asynchronously to the message delivery thread, it is possible that a message is still being /// delivered when this method returns. /// </summary> /// <remarks> /// This method requests its internal lock, so it must not be called while holding other locks, according to the /// MP2 multithreading guidelines. /// </remarks> public void Terminate() { if (_shutdownWatcher != null) { _shutdownWatcher.Remove(); } _shutdownWatcher = null; UnregisterFromAllMessageChannels(); _terminatedEvent.Set(); }
/// <summary> /// Terminates this message queue. Once the queue is terminated, no further messages are delivered. /// But as this method runs asynchronously to the message delivery thread, it is possible that a message is still being /// delivered when this method returns. /// </summary> /// <remarks> /// This method requests its internal lock, so it must not be called while holding other locks, according to the /// MP2 multithreading guidelines. /// A message queue which was terminated by this method may be restarted by calling <see cref="Start"/> again. /// </remarks> public void Terminate() { if (_shutdownWatcher != null) { _shutdownWatcher.Remove(); } _shutdownWatcher = null; UnregisterFromAllMessageChannels(); if (!_terminatedEvent.SafeWaitHandle.IsClosed) { _terminatedEvent.Set(); } }
/// <summary> /// Starts this message queue. /// </summary> public void Start() { if (_messageDeliveryThread != null) { return; } RegisterAtAllMessageChannels(); _shutdownWatcher = ShutdownWatcher.Create(this); _terminatedEvent.Reset(); Thread thread; lock (_syncObj) _messageDeliveryThread = thread = new Thread(DoWork) { Name = string.Format("AMQ '{0}'", _queueName) }; thread.Start(); }
/// <summary> /// Terminates this message queue. Once the queue is terminated, no further messages are delivered. /// But as this method runs asynchronously to the message delivery thread, it is possible that a message is still being /// delivered when this method returns. /// </summary> /// <remarks> /// This method requests its internal lock, so it must not be called while holding other locks, according to the /// MP2 multithreading guidelines. /// A message queue which was terminated by this method may be restarted by calling <see cref="Start"/> again. /// </remarks> public void Terminate() { if (_shutdownWatcher != null) _shutdownWatcher.Remove(); _shutdownWatcher = null; UnregisterFromAllMessageChannels(); if (!_terminatedEvent.SafeWaitHandle.IsClosed) _terminatedEvent.Set(); }
/// <summary> /// Starts this message queue. /// </summary> public void Start() { if (_messageDeliveryThread != null) return; RegisterAtAllMessageChannels(); _shutdownWatcher = ShutdownWatcher.Create(this); _terminatedEvent.Reset(); Thread thread; lock (_syncObj) _messageDeliveryThread = thread = new Thread(DoWork) { Name = string.Format("AMQ '{0}'", _queueName) }; thread.Start(); }
/// <summary> /// Terminates this message queue. Once the queue is terminated, no further messages are delivered. /// But as this method runs asynchronously to the message delivery thread, it is possible that a message is still being /// delivered when this method returns. /// </summary> /// <remarks> /// This method requests its internal lock, so it must not be called while holding other locks, according to the /// MP2 multithreading guidelines. /// A message queue which was terminated by this method may be restarted by calling <see cref="Start"/> again. /// </remarks> public void Terminate() { if (_shutdownWatcher != null) _shutdownWatcher.Remove(); _shutdownWatcher = null; UnregisterFromAllMessageChannels(); _terminatedEvent.Set(); }