MessageQueue-class | R Documentation |
"MessageQueue"
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.
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.
All reference classes extend and inherit methods from
"envRefClass"
.
app
:Object of class character
giving the name
of the application.
The following generic functions are designed to work with subclasses of
message queues, however, currently only the
MongoQueue
has all of the methods.
Removes messages matching query from queue.
Returns the next unprocessed message from the Queue, or 'NULL' if there are no processed messages in the queue.
Imports messages into a queue from a file.
Marks a message as an error, and saves error message in queue.
Marks a message as processed.
Clears the processed flag for messages matching the query.
$initialize(app, ...)
:Constructor.
$count()
:Returns the number of messages remaining in queue.
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.
Russell Almond
MongoQueue
,
ListQueue
,
P4Message
,
MongoDB
,
fetchNextMessage()
,
cleanMessageQueue()
,
importMessages()
,
markAsProcessed()
,
resetProcessedMessages()
,
buildMessage()
,
getOneRec()
showClass("MessageQueue")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.