C# Class Westwind.MessageQueueing.QueueController

This class is a Server Controller that can be run by a Host process to handle processing of message requests in Windows Forms/Service applications. It provides a multi-threaded server process that fires events when messages arrive in the queue and are completed. A client application can simply drop this component into the app and attach to the events provdided here.
Inheritance: IDisposable
Exibir arquivo Open project: RickStrahl/Westwind.QueueMessageManager Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void
Initialize ( QueueMessageManagerConfiguration configuration = null, Type queueManagerType = null ) : void

Initializes the QueueController from the Queue Configuration Settings

PauseProcessing ( bool pause = true ) : void

Pauses processing by keeping the thread alive and waiting until the pause is unset

QueueController ( ) : System
StartProcessing ( ) : void

Synchronous Message Processing routine - will process one message after another

StartProcessingAsync ( int threads = -1 ) : void

Starts queue processing asynchronously on the specified number of threads. This is a common scenario for Windows Forms interfaces so the UI stays active while the application monitors and processes the queue on a separate non-ui thread

StopProcessing ( ) : void

Shuts down the Message Processing loop

Protected Methods

Method Description
ExecuteSteps ( QueueMessageManager manager ) : void

This is the 'handler' code that actually does processing work It merely calls into any events that are hooked up to the controller for these events: ExecuteStart ExecuteComplete ExecuteFailed

OnExecuteComplete ( QueueMessageManager Message ) : void

Override this method to do any post processing that needs to happen after each async operation has successfully completed. Optional - use for things like logging or reporting on status.

OnExecuteFailed ( QueueMessageManager manager, Exception ex ) : void

Override this method to handle any errors that occured during processing of the async task. Optional - implement for logging or notifications.

OnExecuteStart ( QueueMessageManager manager ) : void

Override this method to process your async operation. Required for anything to happen when the message is processed. If the operation succeeds (no exception), OnExecuteComplete will be called. This method should throw an exception if the operation fails, so that OnExecuteFailed will be fired.

OnGetNextQueueMessage ( QueueMessageManager manager, string queueName ) : QueueMessageItem

Message hook that's responsible for retrieving the next message. The base version pulls the next message for the given queue. You can override this method to conditionally override this behavior such as filter when and how messages are read.

OnNextMessageFailed ( QueueMessageManager manager, Exception ex ) : void

Override this method to handle any errors that occured trying to receive the next message from the SQL table. Allows for error handling or logging in your own applications.

OnStartProcessing ( ) : bool

Method that is called just before the the controller starts up processing for the queue. If you return false from this method the controller queue is not started.

OnStopProcessing ( ) : bool

Method that is called just before the controller stops processing requests. Use to send messages. If you return false from this method the queue is not stoped.

Method Details

Dispose() public method

public Dispose ( ) : void
return void

ExecuteSteps() protected method

This is the 'handler' code that actually does processing work It merely calls into any events that are hooked up to the controller for these events: ExecuteStart ExecuteComplete ExecuteFailed
protected ExecuteSteps ( QueueMessageManager manager ) : void
manager QueueMessageManager Instance of QueueMessageManager and it's Item property
return void

Initialize() public method

Initializes the QueueController from the Queue Configuration Settings
public Initialize ( QueueMessageManagerConfiguration configuration = null, Type queueManagerType = null ) : void
configuration QueueMessageManagerConfiguration
queueManagerType System.Type
return void

OnExecuteComplete() protected method

Override this method to do any post processing that needs to happen after each async operation has successfully completed. Optional - use for things like logging or reporting on status.
protected OnExecuteComplete ( QueueMessageManager Message ) : void
Message QueueMessageManager
return void

OnExecuteFailed() protected method

Override this method to handle any errors that occured during processing of the async task. Optional - implement for logging or notifications.
protected OnExecuteFailed ( QueueMessageManager manager, Exception ex ) : void
manager QueueMessageManager /// QueueManager instance. Use its Item property to get access to the current method ///
ex System.Exception /// Exeception that caused the operation to fail ///
return void

OnExecuteStart() protected method

Override this method to process your async operation. Required for anything to happen when the message is processed. If the operation succeeds (no exception), OnExecuteComplete will be called. This method should throw an exception if the operation fails, so that OnExecuteFailed will be fired.
protected OnExecuteStart ( QueueMessageManager manager ) : void
manager QueueMessageManager /// QueueManager instance. Use its Item property to get access to the current method ///
return void

OnGetNextQueueMessage() protected method

Message hook that's responsible for retrieving the next message. The base version pulls the next message for the given queue. You can override this method to conditionally override this behavior such as filter when and how messages are read.
protected OnGetNextQueueMessage ( QueueMessageManager manager, string queueName ) : QueueMessageItem
manager QueueMessageManager A manager instance that can retrieve
queueName string The queue to check
return QueueMessageItem

OnNextMessageFailed() protected method

Override this method to handle any errors that occured trying to receive the next message from the SQL table. Allows for error handling or logging in your own applications.
protected OnNextMessageFailed ( QueueMessageManager manager, Exception ex ) : void
manager QueueMessageManager /// QueueManager instance. Use its Item property to get access to the current method ///
ex System.Exception /// Exeception that caused the operation to fail ///
return void

OnStartProcessing() protected method

Method that is called just before the the controller starts up processing for the queue. If you return false from this method the controller queue is not started.
protected OnStartProcessing ( ) : bool
return bool

OnStopProcessing() protected method

Method that is called just before the controller stops processing requests. Use to send messages. If you return false from this method the queue is not stoped.
protected OnStopProcessing ( ) : bool
return bool

PauseProcessing() public method

Pauses processing by keeping the thread alive and waiting until the pause is unset
public PauseProcessing ( bool pause = true ) : void
pause bool
return void

QueueController() public method

public QueueController ( ) : System
return System

StartProcessing() public method

Synchronous Message Processing routine - will process one message after another
public StartProcessing ( ) : void
return void

StartProcessingAsync() public method

Starts queue processing asynchronously on the specified number of threads. This is a common scenario for Windows Forms interfaces so the UI stays active while the application monitors and processes the queue on a separate non-ui thread
public StartProcessingAsync ( int threads = -1 ) : void
threads int
return void

StopProcessing() public method

Shuts down the Message Processing loop
public StopProcessing ( ) : void
return void