ubq_messages_ns

@unitybase/ubq~ ubq_messages_ns

Message queue. Store messages posted by producers. Consumers read messages from this table and run corresponding tasks

Constructor

new ubq_messages_ns()

Mixes In:
mStorage   

Extends

Members

attrs static

Attributes defined in metadata. This property not exist in real life and added just for help

entity: UBEntity

Reference to entity metadata

Methods

addNew(ctx) api

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:
  1. ctx (ubMethodParams)
Mixes In:
mStorage.addNew   

delete(ctx) api

Delete data
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams.execParams.ID (number)  element ID to be deleted
Mixes In:
mStorage.delete   

insert(ctx) api

Insert new row to the entity.
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams.execParams (Object|TubList)  Object keys is entity attributes names, key values is a value to be inserted
Mixes In:
mStorage.insert   

select(ctx) api

Read entity data
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams (UBQL)  ORM query in UBQL format
Mixes In:
mStorage.select   

update(ctx) api

Update data
Arguments:
  1. ctx (ubMethodParams)
    Properties
    1. mParams.execParams (Object|TubList)  Object keys is entity attributes names, key values is a value to be inserted
      Properties
      1. ID (number)  element ID to be updated
Mixes In:
mStorage.update   

addqueue(ctxt)Boolean api

Add item to queue.

Used by server FTS mixin - do not remove

Arguments:
  1. ctxt (ubMethodParams)
    Properties
    1. mParams.queueCode (String)  Queue code to add a item to
    2. mParams.msgCmd (String)  Command
    3. mParams.msgData (String)  Additional command data
    4. [mParams.msgPriority=0] (Number)  Priority

executeSchedulerTask(nullCtxt, req, resp)Boolean api

REST endpoint for executing a scheduler task. Queue worker will sent 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
 }

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 written to ubq_runstat.resultErrorMsg.
Arguments:
  1. nullCtxt (null)
  2. req (THTTPRequest)  Name of a scheduler item
  3. resp (THTTPResponse)  Command to execute

success(ctxt) api

Mark queue task as successfully executed
Arguments:
  1. ctxt (ubMethodParams)
    Properties
    1. mParams.ID (Number)