InjectionListener-class {Proc4} | 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")
: If
the message is in the messSet
, it saves the message to the
database. (See details)
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(mess)
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(mess)
:Does the work of inserting the message. See Details.
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)