C# Class Westwind.MessageQueueing.QueueMessageManager

An implementation of a SQL based multi-access Queue that provides random acccess to requests so they can be retrived for long running tasks where both client and server can interact with each message for processing. Great for long running tasks or even light workflow scenarios.
Inheritance: IDisposable
Afficher le fichier Open project: RickStrahl/Westwind.QueueMessageManager Class Usage Examples

Protected Properties

Свойство Type Description
_IsNew bool

Méthodes publiques

Méthode Description
CancelRequest ( QueueMessageItem item = null, string messageText = null, bool autoSave = false ) : bool

Sets the Item record with the required settings to complete and cancel a request. Not saved to database call Save() explicitly.

ClearMessages ( System.TimeSpan messageTimeout = null ) : bool

Method used to clear out 'old' messages to keep database size down Removes messages that have been started but not completed in the specified timeout period.

CompleteRequest ( QueueMessageItem item = null, string messageText = null, bool autoSave = false ) : bool

Sets the Item record with the required settings to complete a request. Note record is not written to database - Call Save explicitly.

CreateDatastore ( ) : bool

Creates the DatabaseTable and stored procedure for the queue. Note this routine requires that a database exists already and uses the same connection string that is used for the main application.

CreateItem ( QueueMessageItem entity = null ) : QueueMessageItem

Creates a new item instance and properly initializes the instance's values.

DeleteMessage ( string id ) : bool
DeleteWaitingMessages ( string queueName = null ) : bool
Dispose ( ) : void

Clear data access component

GetCancelledMessages ( string queueName = null, int maxCount ) : IEnumerable

Returns all messages in a queue that are cancelled

GetCompleteQueueMessages ( string queueName = null, int maxCount ) : IEnumerable

Result Cursor: TCompleteMessages

GetNextQueueMessage ( string queueName = null ) : QueueMessageItem

Retrieves the next pending Message from the Queue based on a provided queueName

GetPendingQueueMessages ( string queueName = null, int maxCount ) : IEnumerable

Retrieves all messages that are pending, that have started but not completed yet.

GetProperty ( string key ) : object

Retrieves a value from the Properties collection safely. If the value doesn't exist null is returned.

GetRecentQueueItems ( string queueName = null, int itemCount = 25 ) : IEnumerable

Returns a list of recent queue items

GetTimedOutQueueMessages ( string queueName = null, int maxCount ) : IEnumerable

Returns a list of queue items that have timed out during processing. Not completed where started time is greater than the MessageTimeout.

GetWaitingQueueMessageCount ( string queueName = null ) : int

Returns a count of messages that are waiting to be processed - this is the queue backup.

GetWaitingQueueMessages ( string queueName = null, int maxCount ) : IEnumerable

Returns a count of messages that are waiting to be processed - this is the queue backup.

IsCompleted ( string id = null ) : bool

Determines if anqueue has been completed successfully or failed. Note this method returns true if the request has completed or cancelled/failed. It just checks completion.

Load ( string id ) : QueueMessageItem

Loads a Queue Item

QueueMessageManager ( ) : System
QueueMessageManager ( string connectionString ) : System
ResubmitMessage ( QueueMessageItem item = null ) : bool

Resubmits an existing message by clearing out all completion/date settings and then resubmitting the entry. This method calls Save() and actually saves the message to disk.

Save ( QueueMessageItem item = null ) : bool

Saves the passed item or the attached item to the database. Call this after updating properties or individual values.

SetError ( ) : void

Clear the error messages

SetError ( Exception ex, bool checkInner = false ) : void

Set from exception and optionally use inner exception

SetError ( string message ) : void

Set error to the error message

SubmitRequest ( QueueMessageItem item = null, string messageText = null, bool autoSave = false ) : bool

Sets the message properties for starting a new message request operation. Note the record is not written to the database use Save explicitly

UpdateQueueMessageStatus ( QueueMessageItem item = null, string status = null, string messageText = null, int percentComplete = -1, bool autoSave = false ) : bool

Updates the QueueMessageStatus and or messages

Méthodes protégées

Méthode Description
GetProperties ( string stringFieldNameToLoadFrom = "Properties", object entity = null ) : void

Loads the Properties dictionary with values from a Properties property of an item object. Once loaded you can access the dictionary to read and write values from it arbitrarily and use SetProperties to write the values back in serialized form to the underlying property for database storage.

SetProperties ( string stringFieldToSaveTo = "Properties", object entity = null ) : void

Saves the Properties Dictionary - in serialized string form - to a specified item field which in turn allows writing the data back to the database.

Method Details

CancelRequest() public méthode

Sets the Item record with the required settings to complete and cancel a request. Not saved to database call Save() explicitly.
public CancelRequest ( QueueMessageItem item = null, string messageText = null, bool autoSave = false ) : bool
item QueueMessageItem
messageText string
autoSave bool
Résultat bool

ClearMessages() public abstract méthode

Method used to clear out 'old' messages to keep database size down Removes messages that have been started but not completed in the specified timeout period.
public abstract ClearMessages ( System.TimeSpan messageTimeout = null ) : bool
messageTimeout System.TimeSpan
Résultat bool

CompleteRequest() public méthode

Sets the Item record with the required settings to complete a request. Note record is not written to database - Call Save explicitly.
public CompleteRequest ( QueueMessageItem item = null, string messageText = null, bool autoSave = false ) : bool
item QueueMessageItem
messageText string
autoSave bool
Résultat bool

CreateDatastore() public abstract méthode

Creates the DatabaseTable and stored procedure for the queue. Note this routine requires that a database exists already and uses the same connection string that is used for the main application.
public abstract CreateDatastore ( ) : bool
Résultat bool

CreateItem() public méthode

Creates a new item instance and properly initializes the instance's values.
public CreateItem ( QueueMessageItem entity = null ) : QueueMessageItem
entity QueueMessageItem
Résultat QueueMessageItem

DeleteMessage() public abstract méthode

public abstract DeleteMessage ( string id ) : bool
id string
Résultat bool

DeleteWaitingMessages() public abstract méthode

public abstract DeleteWaitingMessages ( string queueName = null ) : bool
queueName string
Résultat bool

Dispose() public méthode

Clear data access component
public Dispose ( ) : void
Résultat void

GetCancelledMessages() public abstract méthode

Returns all messages in a queue that are cancelled
public abstract GetCancelledMessages ( string queueName = null, int maxCount ) : IEnumerable
queueName string
maxCount int
Résultat IEnumerable

GetCompleteQueueMessages() public abstract méthode

Result Cursor: TCompleteMessages
public abstract GetCompleteQueueMessages ( string queueName = null, int maxCount ) : IEnumerable
queueName string
maxCount int
Résultat IEnumerable

GetNextQueueMessage() public abstract méthode

Retrieves the next pending Message from the Queue based on a provided queueName
public abstract GetNextQueueMessage ( string queueName = null ) : QueueMessageItem
queueName string
Résultat QueueMessageItem

GetPendingQueueMessages() public abstract méthode

Retrieves all messages that are pending, that have started but not completed yet.
public abstract GetPendingQueueMessages ( string queueName = null, int maxCount ) : IEnumerable
queueName string Name of the queue to return items for
maxCount int Optional - max number of items to return
Résultat IEnumerable

GetProperties() protected méthode

Loads the Properties dictionary with values from a Properties property of an item object. Once loaded you can access the dictionary to read and write values from it arbitrarily and use SetProperties to write the values back in serialized form to the underlying property for database storage.
protected GetProperties ( string stringFieldNameToLoadFrom = "Properties", object entity = null ) : void
stringFieldNameToLoadFrom string The name of the field to load the XML properties from.
entity object
Résultat void

GetProperty() public méthode

Retrieves a value from the Properties collection safely. If the value doesn't exist null is returned.
public GetProperty ( string key ) : object
key string
Résultat object

GetRecentQueueItems() public abstract méthode

Returns a list of recent queue items
public abstract GetRecentQueueItems ( string queueName = null, int itemCount = 25 ) : IEnumerable
queueName string
itemCount int
Résultat IEnumerable

GetTimedOutQueueMessages() public abstract méthode

Returns a list of queue items that have timed out during processing. Not completed where started time is greater than the MessageTimeout.
public abstract GetTimedOutQueueMessages ( string queueName = null, int maxCount ) : IEnumerable
queueName string
maxCount int
Résultat IEnumerable

GetWaitingQueueMessageCount() public abstract méthode

Returns a count of messages that are waiting to be processed - this is the queue backup.
public abstract GetWaitingQueueMessageCount ( string queueName = null ) : int
queueName string
Résultat int

GetWaitingQueueMessages() public abstract méthode

Returns a count of messages that are waiting to be processed - this is the queue backup.
public abstract GetWaitingQueueMessages ( string queueName = null, int maxCount ) : IEnumerable
queueName string
maxCount int
Résultat IEnumerable

IsCompleted() public abstract méthode

Determines if anqueue has been completed successfully or failed. Note this method returns true if the request has completed or cancelled/failed. It just checks completion.
public abstract IsCompleted ( string id = null ) : bool
id string
Résultat bool

Load() public abstract méthode

Loads a Queue Item
public abstract Load ( string id ) : QueueMessageItem
id string
Résultat QueueMessageItem

QueueMessageManager() public méthode

public QueueMessageManager ( ) : System
Résultat System

QueueMessageManager() public méthode

public QueueMessageManager ( string connectionString ) : System
connectionString string
Résultat System

ResubmitMessage() public méthode

Resubmits an existing message by clearing out all completion/date settings and then resubmitting the entry. This method calls Save() and actually saves the message to disk.
public ResubmitMessage ( QueueMessageItem item = null ) : bool
item QueueMessageItem
Résultat bool

Save() public abstract méthode

Saves the passed item or the attached item to the database. Call this after updating properties or individual values.
public abstract Save ( QueueMessageItem item = null ) : bool
item QueueMessageItem
Résultat bool

SetError() public méthode

Clear the error messages
public SetError ( ) : void
Résultat void

SetError() public méthode

Set from exception and optionally use inner exception
public SetError ( Exception ex, bool checkInner = false ) : void
ex System.Exception
checkInner bool
Résultat void

SetError() public méthode

Set error to the error message
public SetError ( string message ) : void
message string
Résultat void

SetProperties() protected méthode

Saves the Properties Dictionary - in serialized string form - to a specified item field which in turn allows writing the data back to the database.
protected SetProperties ( string stringFieldToSaveTo = "Properties", object entity = null ) : void
stringFieldToSaveTo string
entity object
Résultat void

SubmitRequest() public méthode

Sets the message properties for starting a new message request operation. Note the record is not written to the database use Save explicitly
public SubmitRequest ( QueueMessageItem item = null, string messageText = null, bool autoSave = false ) : bool
item QueueMessageItem An existing item instance
messageText string
autoSave bool
Résultat bool

UpdateQueueMessageStatus() public méthode

Updates the QueueMessageStatus and or messages
public UpdateQueueMessageStatus ( QueueMessageItem item = null, string status = null, string messageText = null, int percentComplete = -1, bool autoSave = false ) : bool
item QueueMessageItem
status string
messageText string
percentComplete int
autoSave bool
Résultat bool

Property Details

_IsNew protected_oe property

protected bool _IsNew
Résultat bool