Messages queue. Store messages posted by producers. Consumers read messages from this table and run corresponding tasks
# new ubq_messages_ns ()
Members
# attrs : ubqMessagesAttrs static
Attributes defined in metadata. Property does not exist in real life and added for IDE
# entity : UBEntity instance
Reference to entity metadata
Methods
# addNew (ctx: ubMethodParams) instance
Create record with filled default values and return it to caller.
Newly created record is not inserted to database. For inserting record to the database insert
method should be called
Arguments:
ctx
: ubMethodParamsmParams
: objectOptional values for attributes of new record
# delete (ctx: ubMethodParams) instance
Delete record by ID
Arguments:
ctx
: ubMethodParamsmParams
: objectDelete method parameters
# insert (ctx: ubMethodParams) instance
New record insertion
Arguments:
ctx
: ubMethodParamsmParams
: objectInsert method parameters
# select (ctx: ubMethodParams) instance
ORM query for read records
Arguments:
ctx
: ubMethodParamsmParams
: UBQLORM query in UBQL format
# update (ctx: ubMethodParams) instance
Update existed record
Arguments:
ctx
: ubMethodParams
# addqueue (ctxt: ubMethodParams) → Boolean instance
Add item to queue. Used by server FTS mixin - do not remove
Arguments:
ctxt
: ubMethodParams
# executeSchedulerTask (nullCtxt: null, req: THTTPRequest, resp: THTTPResponse) → Boolean instance
REST endpoint for executing a scheduler task. Queue worker will send the tasks in async mode to this endpoint according to a schedulers. Endpoint wait a POST requests from a local IP with JSON in body:
{
schedulerName: cfg.name, command: cfg.command, module: cfg.module,
singleton: cfg.singleton !== false, logSuccessful: cfg.logSuccessful,
runAsID: optional user ID for runAs
}
command
must be a function name (may including namespace), for example UB.UBQ.sendQueueMail
or ubs_message_edit.notifyAllRecipients
in case command
not passed module
must be a module what export default a function, for example module: '@unitybase/myModule/schedTask'
and in schedTask.js: module exports = function() {...}
In case singleton
parameter is missing or === false scheduler can run a multiple instances of the same task,
otherwise - if previous task with the same name not finished yet current task will not be executed
- If command executed success, record with resultError===0 will be written to
ubq_runstat
entity. - If command executed with exception, record with resultError===1 will be written to
ubq_runstat
entity, Exception text will be written toubq_runstat.resultErrorMsg
.
Arguments:
nullCtxt
: nullreq
: THTTPRequestName of a scheduler item
resp
: THTTPResponseCommand to execute
# success (ctxt: ubMethodParams) instance
Mark queue task as successfully executed
Arguments:
ctxt
: ubMethodParams