Module basic module

Module mq

Message queue module



Create a message object, see Message

Message mq.Message;


Create an http protocol handler object, see HttpHandler

HttpHandler mq.HttpHandler;


Create a message handler object, pass the value built-in handler directly returns

Handler mq.Handler;

Return result:

  • Returns the processor that encapsulates the processing function

hdlr accepts built-in message handlers, processing functions, chain processing arrays, and routing objects:

  • Function javascript function, will use this function for processing
  • Handler built-in processor, will use this processor for processing
  • Chain processing array, equivalent to returning new mq.Chain (hdlr), see Chain
  • Routing object, equivalent to returning new mq.Routing (hdlr), see Routing

The message processing function syntax is as follows:

function func(v) {}

The parameter v is the message being processed, and the return result allows four types:

  • Function javascript function, this function will be used for the next stage of processing
  • Handler built-in processor, this processor will be used for the next stage of processing
  • Chain processing array, equivalent to new mq.Chain (v), see Chain
  • Routing object, equivalent to new mq.Routing (v), see Routing

No return or other return results will end the message processing.


Create a message processor chain processing object, see Chain

Chain mq.Chain;


Create a message processor routing object, see Routing

Routing mq.Routing;

Static function


Create an empty handler object, and the secondary handler will return directly without any processing

static Handler mq.nullHandler();

Return result:

  • Handler , returns an empty handler function


Use a given processor to process a message or object

1 2
static mq.invoke(Handler hdlr, object v) async;

Call parameters:

  • hdlr : Handler , specify the processor used
  • v : object , specify the message or object to be processed

Different from the invoke method of the processor, this method will call the return processor of each processor in a loop until the processor returns null.