Module basic module

Module mq

Message queue module

Object

Message

Create a message object, see Message

1
Message mq.Message;

HttpHandler

Create http Protocol handler object, see HttpHandler

1
HttpHandler mq.HttpHandler;

Handler

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

1
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
  • Route object, equivalent to returning new mq.Routing(hdlr), see Routing

The message processing function syntax is as follows:

1
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
  • Route object, equivalent to new mq.Routing(v), see Routing

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


Chain

Create a message processor chain processing object, see Chain

1
Chain mq.Chain;

Routing

Create a message handler routing object, see Routing

1
Routing mq.Routing;

Static function

nullHandler

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

1
static Handler mq.nullHandler();

Return result:


invoke

Use a given processor to process a message or object

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

Call parameters:

  • hdlr: Handler, The specified processor
  • 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.