C# Класс 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.
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
_IsNew bool

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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.

Описание методов

CancelRequest() публичный Метод

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
Результат bool

ClearMessages() публичный абстрактный Метод

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
Результат bool

CompleteRequest() публичный Метод

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
Результат bool

CreateDatastore() публичный абстрактный Метод

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
Результат bool

CreateItem() публичный Метод

Creates a new item instance and properly initializes the instance's values.
public CreateItem ( QueueMessageItem entity = null ) : QueueMessageItem
entity QueueMessageItem
Результат QueueMessageItem

DeleteMessage() публичный абстрактный Метод

public abstract DeleteMessage ( string id ) : bool
id string
Результат bool

DeleteWaitingMessages() публичный абстрактный Метод

public abstract DeleteWaitingMessages ( string queueName = null ) : bool
queueName string
Результат bool

Dispose() публичный Метод

Clear data access component
public Dispose ( ) : void
Результат void

GetCancelledMessages() публичный абстрактный Метод

Returns all messages in a queue that are cancelled
public abstract GetCancelledMessages ( string queueName = null, int maxCount ) : IEnumerable
queueName string
maxCount int
Результат IEnumerable

GetCompleteQueueMessages() публичный абстрактный Метод

Result Cursor: TCompleteMessages
public abstract GetCompleteQueueMessages ( string queueName = null, int maxCount ) : IEnumerable
queueName string
maxCount int
Результат IEnumerable

GetNextQueueMessage() публичный абстрактный Метод

Retrieves the next pending Message from the Queue based on a provided queueName
public abstract GetNextQueueMessage ( string queueName = null ) : QueueMessageItem
queueName string
Результат QueueMessageItem

GetPendingQueueMessages() публичный абстрактный Метод

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
Результат IEnumerable

GetProperties() защищенный Метод

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
Результат void

GetProperty() публичный Метод

Retrieves a value from the Properties collection safely. If the value doesn't exist null is returned.
public GetProperty ( string key ) : object
key string
Результат object

GetRecentQueueItems() публичный абстрактный Метод

Returns a list of recent queue items
public abstract GetRecentQueueItems ( string queueName = null, int itemCount = 25 ) : IEnumerable
queueName string
itemCount int
Результат IEnumerable

GetTimedOutQueueMessages() публичный абстрактный Метод

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
Результат IEnumerable

GetWaitingQueueMessageCount() публичный абстрактный Метод

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
Результат int

GetWaitingQueueMessages() публичный абстрактный Метод

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
Результат IEnumerable

IsCompleted() публичный абстрактный Метод

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
Результат bool

Load() публичный абстрактный Метод

Loads a Queue Item
public abstract Load ( string id ) : QueueMessageItem
id string
Результат QueueMessageItem

QueueMessageManager() публичный Метод

public QueueMessageManager ( ) : System
Результат System

QueueMessageManager() публичный Метод

public QueueMessageManager ( string connectionString ) : System
connectionString string
Результат System

ResubmitMessage() публичный Метод

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
Результат bool

Save() публичный абстрактный Метод

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
Результат bool

SetError() публичный Метод

Clear the error messages
public SetError ( ) : void
Результат void

SetError() публичный Метод

Set from exception and optionally use inner exception
public SetError ( Exception ex, bool checkInner = false ) : void
ex System.Exception
checkInner bool
Результат void

SetError() публичный Метод

Set error to the error message
public SetError ( string message ) : void
message string
Результат void

SetProperties() защищенный Метод

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
Результат void

SubmitRequest() публичный Метод

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
Результат bool

UpdateQueueMessageStatus() публичный Метод

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
Результат bool

Описание свойств

_IsNew защищенное свойство

protected bool _IsNew
Результат bool