Module basic module

module mq

message queue module

object

Message

Create a message object, seeMessage

1
Message mq.Message;

HttpHandler

Createhttpprotocol handler object, seeHttpHandler

1
HttpHandler mq.HttpHandler;

Handler

Create a message processor object, pass the value to the built-in processor and return it directly

1
Handler mq.Handler;

Return results:

  • Returns the processor encapsulating the processing function

hdlr accepts built-in message processors, processing functions, chained processing arrays, and routing objects:

  • Function javascript function, this function will be used for processing
  • HandlerBuilt-in processor, this processor will be used for processing
  • Processing arrays in a chain is equivalent to returning newmq.Chain(hdlr), seeChain
  • Routing object, equivalent to returning newmq.Routing(hdlr), seeRouting

The message processing function syntax is as follows:

1
function func(v) {}

Parameter v is the message being processed, and four types of return results are allowed:

  • Function javascript function, this function will be used for the next stage of processing
  • HandlerBuilt-in processor, this processor will be used for the next stage of processing
  • Chain processing of arrays, equivalent to newmq.Chain(v), seeChain
  • Routing object, equivalent to newmq.Routing(v), seeRouting

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


Chain

Create a message handler chain processing object, seeChain

1
Chain mq.Chain;

Routing

Create a message handler routing object, seeRouting

1
Routing mq.Routing;

static function

nullHandler

Create an empty processor object, and the secondary processing object will be returned directly without any processing.

1
static Handler mq.nullHandler();

Return results:

  • Handler, returns an empty handler function

invoke

Process a message or object using the given handler

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

Call parameters:

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

Unlike the processor's invoke method, this method will loop through each processor's return handler until the processor returns null.