MessageQueue-class: Class '"MessageQueue"'

MessageQueue-classR Documentation

Class "MessageQueue"

Description

A message queue is an ordered collection of P4Message objects. The principle idea is that the fetchNextMessage() function will fetch the next unprocessed message, and consequently, this can be used to schedule the work for a scoring engine.

Details

The general queue functions are determined by two generic functions: fetchNextMessage(), and markAsProcessed(). The fetchNextMessage() returns the “first” (the meaning of first is defined by the implementing Queue object) unprocssed message (i.e., processed(mess)=FALSE). Note that the fetchNextMessage() function will continue to return the same message until it is marked as processed using markAsProcessed(queue,mess). Note that simply setting processed(mess) <- FALSE is not sufficient because the change is not stored in the queue.

Extends

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

Fields

app:

Object of class character giving the name of the application.

GenericFunctions

The following generic functions are designed to work with subclasses of message queues, however, currently only the MongoQueue has all of the methods.

cleanMessageQueue:

Removes messages matching query from queue.

fetchNextMessage:

Returns the next unprocessed message from the Queue, or 'NULL' if there are no processed messages in the queue.

importMessages:

Imports messages into a queue from a file.

markAsError:

Marks a message as an error, and saves error message in queue.

markAsProcessed:

Marks a message as processed.

resetProcessedMessages:

Clears the processed flag for messages matching the query.

Class-Based Methods

$initialize(app, ...):

Constructor.

$count():

Returns the number of messages remaining in queue.

Note

The current implementations are MongoQueue which uses a database collection for the queue, and a partially implemented ListQueue which just uses an array of messages. This is not fully implemented.

Some other alternatives would be to link to a formal queuing system, like Kafka, or to some kind of RPC server.

Author(s)

Russell Almond

See Also

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

Examples

showClass("MessageQueue")

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