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

Mixes In:

# 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 (ctxubMethodParams) 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:

# delete (ctxubMethodParams) instance

Delete record by ID

Arguments:

# insert (ctxubMethodParams) instance

New record insertion

Arguments:

# select (ctxubMethodParams) instance

ORM query for read records

Arguments:

# update (ctxubMethodParams) instance

Update existed record

Arguments:
  • ctx: ubMethodParams
    • mParamsobject

      Update method parameters

    • fieldListarray.<string>

      Optional attributes names. Values of this attributes will be returned in result. Additional DB query is required to return values, so if caller do not need it better to not pass a fieldList to update

# addqueue (ctxtubMethodParams) → Boolean instance

Add item to queue. Used by server FTS mixin - do not remove

Arguments:

# executeSchedulerTask (nullCtxtnull, reqTHTTPRequest, respTHTTPResponse) → 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 to ubq_runstat.resultErrorMsg.

Arguments:

# success (ctxtubMethodParams) instance

Mark queue task as successfully executed

Arguments: