Difference between revisions of "MQCREATE()"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
{{YLM to do}}
 
 
==Purpose==
 
==Purpose==
 
Create a message queue and open a pointer to the queue
 
Create a message queue and open a pointer to the queue
Line 9: Line 8:
  
 
==See Also==
 
==See Also==
[[MQCLOSE()]], [[MQCURMSGS()]], [[MQOPEN()]],  [[MQRECEIVE()]], [[MQSEND()]]
+
[[MQCLOSE()]], [[MQCURMSGS()]], [[MQOPEN()]],  [[MQRECEIVE()]], [[MQSEND()]], [[MQUNLINK()]], [[XML_DECODE()]], [[XML_ENCODE()]], [[XML_GATHER()]], [[XML_SCATTER()]]
  
  
 
==Description==
 
==Description==
The MQOPEN() function opens an existing message queue.  It returns a numeric pointer when the queue is opened successfully, or a -1 if unsuccessful.  The <expC> is the name of the queue to open.  Since the pointer is required to identify an open queue to other messaging functions, always assign the return value to a memory variable.  The optional <expN> determines the queue access mode:
+
The MQCREATE() function creates and opens a new message queue.  It returns a numeric pointer when the queue is opened successfully, or a -1 if unsuccessful.  The <expC> is the name of the queue to create and open.  Since the pointer is required to identify an open queue to other messaging functions, always assign the return value to a memory variable.  The optional <expN> determines the queue access mode:
  
  
Line 19: Line 18:
 
!<expN>||Access Mode
 
!<expN>||Access Mode
 
|-
 
|-
|?||?
+
|Unspecified||Read only access
 
|-
 
|-
|?||?
+
|0||Read only access
 
|-
 
|-
|?||?
+
|1||Write only access
 
|-
 
|-
|?||?
+
|2||Read/Write access
 
|-
 
|-
 
|}
 
|}
  
  
The MQCLOSE() function is used to close a queue which has been opened with MQOPEN().
+
The MQCLOSE() function is used to close a queue which has been opened with MQCREATE() or MQOPEN().
 +
 
 +
For more examples of handling message queues, please see the examples/mqueue programs in the software distribution.
  
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
mqdes=mqopen("/myqueue")
+
// Open up the queue for read/write access
 +
mqdes=mqcreate("/myqueue2", 2)
 
if (mqdes < 0)
 
if (mqdes < 0)
  messagebox(strerror()+",errno="+alltrim(str(error())))
+
    messagebox(strerror()+",errno="+alltrim(str(error())))
  return
+
    return
 +
endif
 +
// send a message to the queue
 +
rc = mqsend(mqdes, "Test message")
 +
if (rc < 0)
 +
    messagebox(strerror()+",errno="+alltrim(str(error())))
 +
    return
 
endif
 
endif
do while (mqcurmsgs(mqdes) > 0)
 
  mstr=mqreceive(mqdes)
 
  if (empty(mstr))
 
      messagebox(strerror()+",errno="+alltrim(str(error())))
 
      return
 
  endif
 
  messagebox(mstr)
 
end do
 
 
mqclose(mqdes)
 
mqclose(mqdes)
 
</code>
 
</code>

Latest revision as of 10:09, 5 July 2011

Purpose

Create a message queue and open a pointer to the queue


Syntax

MQCREATE(<expC> [,<expN>])


See Also

MQCLOSE(), MQCURMSGS(), MQOPEN(), MQRECEIVE(), MQSEND(), MQUNLINK(), XML_DECODE(), XML_ENCODE(), XML_GATHER(), XML_SCATTER()


Description

The MQCREATE() function creates and opens a new message queue. It returns a numeric pointer when the queue is opened successfully, or a -1 if unsuccessful. The <expC> is the name of the queue to create and open. Since the pointer is required to identify an open queue to other messaging functions, always assign the return value to a memory variable. The optional <expN> determines the queue access mode:


<expN> Access Mode
Unspecified Read only access
0 Read only access
1 Write only access
2 Read/Write access


The MQCLOSE() function is used to close a queue which has been opened with MQCREATE() or MQOPEN().

For more examples of handling message queues, please see the examples/mqueue programs in the software distribution.


Example

// Open up the queue for read/write access
mqdes=mqcreate("/myqueue2", 2)
if (mqdes < 0)
    messagebox(strerror()+",errno="+alltrim(str(error())))
    return
endif
// send a message to the queue
rc = mqsend(mqdes, "Test message")
if (rc < 0)
    messagebox(strerror()+",errno="+alltrim(str(error())))
    return
endif
mqclose(mqdes)


Products

Recital, Recital Server