MQSENDMESSAGE()

From Lianjapedia
Revision as of 04:06, 30 March 2017 by Yvonne.milne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Send a message to a named message queue

Syntax

MQSENDMESSAGE(<cQueue>, <cJSON>)

See Also

JSON_DECODE(), JSON_DECODE_FILE(), JSON_ENCODE(), MQCLOSE(), MQCREATE(), MQCURMSGS(), MQOPEN(), MQRECEIVE(), MQSEND(), MQUNLINK(), XML_DECODE(), XML_ENCODE(), XML_GATHER(), XML_SCATTER()

Description

The MQSENDMESSAGE() function sends a message to a named message queue.

Argument Description
<cQueue> Character string specifying the name of the queue
<cJSON> Character string containing JSON encoded message

Example

// Consumer
local mqdes, msg, data
 
// Create the consumer and wait for a connection
mqdes = mqCreate("unique_name_of_your_consumer")
 
// loop processing messages as they come in from multiple producers
do while .t.
       msg = mqReceive(mqdes)
        if len(msg)=0
            loop
        endif
        data = json_decode(msg)
        // Process the message which is now encoded as an object
        // ...
enddo
// ...
mqclose(mqdes)
 
// Producer using MQSENDMESSAGE()
// ...
mqSendMessage(“unique_name_of_your_consumer”,  json_encode(anobject))
 
// or
 
// Producer using MQSEND()
// ...
mqdes = mqOpen(“unique_name_of_your_consumer”)
msg = json_encode(anobject)
mqSend(mqdes, msg)
mqClose(mqdes)