MongoQueue: Class '"MongoQueue"'

MongoQueue-classR Documentation

Class "MongoQueue"

Description

This is a message queue implemented as a database collection.

This wraps a collection in a Mongo (or other JSON-based) database. The fetchNextMessage looks for the first (earliest timestamp) message which is not processed.

Extends

Class "MessageQueue", directly.

All reference classes extend and inherit methods from "envRefClass".

Methods

cleanMessageQueue

signature(queue = "MongoQueue"): Removes messages matching query from queue.

fetchNextMessage

signature(queue = "MessageQueue"): Returns the next unprocessed message from the Queue, or 'NULL' if there are no processed messages in the queue.

importMessages

signature(queue = "MongoQueue"): Imports messages into a queue from a file.

markAsError

signature(col = "MongoQueue", mess = "ANY"): Marks a message as an error, and saves error message in queue.

markAsProcessed

signature(col = "MongoQueue", mess = "ANY"): Marks a message as processed.

resetProcessedMessages

signature(queue = "MongoQueue"): Clears the processed flag for messages matching the query.

Fields

app:

Object of class character giving the identifier of the application. This is used to restrict the app field of the message to match the current application.

messDB:

Object of class JSONDB that provides a reference to the database collection storing the messages.

builder:

Object of class function which is used to reconstruct the messages from the data, see buildMessage() and getOneRec().

Class-Based Methods

$queue():

Returns the JSONDB reference.

$initialize(app, messDB, builder, ...):

Constructor.

$fetchNextMessage():

Internal implementation of the fetch method.

$buildIndex():

This method builds an index in the collection. Generally only needs to be done once.

$count():

Returns the number of unprocessed messages remaining in queue.

Note

It is probably a good idea to build an index on this database using the “processed” and “timestamp” fields. The $buildIndex() method does this.

Author(s)

Russell Almond

See Also

MessageQueue,P4Message, MongoDB, fetchNextMessage(), cleanMessageQueue(), importMessages(), markAsProcessed(), resetProcessedMessages(), buildMessage(), getOneRec()

Examples

showClass("MongoQueue")

ralmond/Proc4 documentation built on June 13, 2025, 7:13 a.m.