InjectionListener-class | R Documentation |
"InjectionListener"
This listener takes messages that match its incomming set and inject them into another Mongo database (presumably a queue for another service).
The database is a mongo
collection identified
by dburi
, dbname
and colname
(collection within
the database). The mess
field of the P4Message
is checked against the applicable messages in messSet
. If it
is there, then the message is inserted into the collection.
This class implements the Listener
interface.
All reference classes extend and inherit methods from "envRefClass"
.
signature(x = "InjectionListener")
: returns
true.
signature(x = "InjectionListener", message)
: If
the message is in the messSet
, it saves the message to the
database. (See details)
signature(x= "InjectionListener")
: Returns the name assigned to the listener.
signature(listener =
"InjectionListener", appid )
: Builds a data datable from the messages.
When the listenerDataTable
method is called,
a general find query (mdbFind
on the backing
collection. The app
, uid
, context
,
timestamp
fields are selected, and the data
(details)
field is unpackaged and added as additional columns.
sender
:Object of class character
which is used
as the sender field for the message.
dbname
:Object of class character
giving the
name of the Mongo database
dburi
:Object of class character
giving the url
of the Mongo database.
colname
:Object of class character
giving the
column of the Mongo database.
messSet
:A vector of class character
giving the
name of messages which are sent to the database. Only messages
for which mess(message)
is an element of messSet
will
be inserted.
db
:Object of class MongoDB
giving the
database. Use messdb()
to access this field to makes sure
it has been set up.
messdb()
:Accessor for the database collection. Initializes the connection if it has not been set up.
receiveMessage(message)
:Does the work of inserting the message. See Details.
reset(app)
:Empties the database collection of messages with this app id.
initialize(sender, dbname, dburi, colname, messSet,
...)
:Sets default values for fields.
Russell Almond
This is an example of the observer design pattern. https://en.wikipedia.org/wiki/Observer_pattern.
Listener
, P4Message
,
InjectionListener
,
UpdateListener
,
UpsertListener
,
CaptureListener
,
TableListener
,
mongo
## Not run:
mess1 <- P4Message(app="default",uid="Phred",context="Down Hill",
sender="EIEvent",mess="New Observables",
details=list(trophy="gold",solvedtime=10))
ilwind <- InjectionListener(sender="EIEvent",messSet="New Observables")
receiveMessage(ilwind,mess1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.