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
Afficher le fichier Open project: RickStrahl/Westwind.QueueMessageManager Class Usage Examples

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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 méthode

public Dispose ( ) : void
Résultat void

ExecuteSteps() protected méthode

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
Résultat void

Initialize() public méthode

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

OnExecuteComplete() protected méthode

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
Résultat void

OnExecuteFailed() protected méthode

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 ///
Résultat void

OnExecuteStart() protected méthode

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 ///
Résultat void

OnGetNextQueueMessage() protected méthode

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
Résultat QueueMessageItem

OnNextMessageFailed() protected méthode

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 ///
Résultat void

OnStartProcessing() protected méthode

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
Résultat bool

OnStopProcessing() protected méthode

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
Résultat bool

PauseProcessing() public méthode

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

QueueController() public méthode

public QueueController ( ) : System
Résultat System

StartProcessing() public méthode

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

StartProcessingAsync() public méthode

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
Résultat void

StopProcessing() public méthode

Shuts down the Message Processing loop
public StopProcessing ( ) : void
Résultat void