C# Class Westwind.MessageQueueing.QueueMessageManagerMongoDb

An implementation of a MongoDb 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. This implementation uses purely MongoDb server data access to handle the queue which works well for low to high volume loads. Great for long running tasks or even light workflow scenarios.
Inheritance: QueueMessageManager
Mostra file Open project: RickStrahl/Westwind.QueueMessageManager

Public Methods

Method Description
ClearMessages ( System.TimeSpan messageTimeout = null ) : bool
CreateDatastore ( ) : bool
DeleteMessage ( string id ) : bool

Deletes an individual queue message by Id

DeleteWaitingMessages ( string queueName = null ) : bool

Deletes all messages that are waiting to be processed

Dispose ( ) : void

Clear data access component

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

Retrieves the next waiting 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.

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

Returns a list of recent queue items

GetTimedOutQueueMessages ( string queueName = null, int maxCount ) : IEnumerable
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 for completion.

Load ( string id ) : QueueMessageItem

Loads a Queue Message Item by its ID

QueueMessageManagerMongoDb ( ) : System
QueueMessageManagerMongoDb ( string connectionString ) : System
Save ( QueueMessageItem item = null ) : bool

Saves the passed message item or the attached item to the database. Call this after updating properties or individual values. Inserts or updates based on whether the ID exists

Protected Methods

Method Description
GetDatabase ( string connectionString = null, string databaseName = null ) : MongoDatabase

Creates a connection to a databaseName based on the Databasename and optional server connection string. Returned Mongo DatabaseName 'connection' can be cached and reused.

Method Details

ClearMessages() public method

public ClearMessages ( System.TimeSpan messageTimeout = null ) : bool
messageTimeout System.TimeSpan
return bool

CreateDatastore() public method

public CreateDatastore ( ) : bool
return bool

DeleteMessage() public method

Deletes an individual queue message by Id
public DeleteMessage ( string id ) : bool
id string
return bool

DeleteWaitingMessages() public method

Deletes all messages that are waiting to be processed
public DeleteWaitingMessages ( string queueName = null ) : bool
queueName string
return bool

Dispose() public method

Clear data access component
public Dispose ( ) : void
return void

GetCancelledMessages() public method

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

GetCompleteQueueMessages() public method

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

GetDatabase() protected method

Creates a connection to a databaseName based on the Databasename and optional server connection string. Returned Mongo DatabaseName 'connection' can be cached and reused.
protected GetDatabase ( string connectionString = null, string databaseName = null ) : MongoDatabase
connectionString string Mongo server connection string. /// Can either be a connection string entry name from the ConnectionStrings /// section in the config file or a full server string. /// If not specified looks for connectionstring entry in same name as /// the context. Failing that mongodb://localhost is used. /// /// Examples: /// MyDatabaseConnectionString (ConnectionStrings Config Name) /// mongodb://localhost /// mongodb://localhost:22011/MyDatabase /// mongodb://username:password@localhost:22011/MyDatabase ///
databaseName string Name of the databaseName to work with if not specified on the connection string
return MongoDatabase

GetNextQueueMessage() public method

Retrieves the next waiting Message from the Queue based on a provided queueName
public GetNextQueueMessage ( string queueName = null ) : QueueMessageItem
queueName string Name of the queue
return QueueMessageItem

GetPendingQueueMessages() public method

Retrieves all messages that are pending, that have started but not completed yet.
public 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
return IEnumerable

GetRecentQueueItems() public method

Returns a list of recent queue items
public GetRecentQueueItems ( string queueName = null, int itemCount = 25 ) : IEnumerable
queueName string
itemCount int Max number of items to return
return IEnumerable

GetTimedOutQueueMessages() public method

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

GetWaitingQueueMessageCount() public method

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

GetWaitingQueueMessages() public method

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

IsCompleted() public method

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 for completion.
public IsCompleted ( string id = null ) : bool
id string
return bool

Load() public method

Loads a Queue Message Item by its ID
public Load ( string id ) : QueueMessageItem
id string
return QueueMessageItem

QueueMessageManagerMongoDb() public method

public QueueMessageManagerMongoDb ( ) : System
return System

QueueMessageManagerMongoDb() public method

public QueueMessageManagerMongoDb ( string connectionString ) : System
connectionString string
return System

Save() public method

Saves the passed message item or the attached item to the database. Call this after updating properties or individual values. Inserts or updates based on whether the ID exists
public Save ( QueueMessageItem item = null ) : bool
item QueueMessageItem
return bool