You might want to have a look at http://systeminetwork.com/node/61315.

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"Millions long for immortality who do not know what to do with themselves on
a rainy Sunday afternoon."
-- Susan Ertz


First of all thanks for your answer, it help me a lot, now i can make
it work.

About reading, you wont believe me but, i read all that stuff you said
there. I'd been in all those places haha, even downloaded "ILE C/C++ MI
Library Reference"
My problem was not undestand what i read, i was expecting that the
structure _ENQ_Msg_Prefix_T would have a field like "Key", so i can put
the key in ( just like in _DEQ_Msg_Prefix_T there is a key field ). I
don't know why IBM don't put the key field... but my problem is solved
now

By the way, i could not find one simple example in all those places you
mention, where keyed queue is used, whyyyyy?. The closest i get was a
creation of a keyed queue

Thanks again

From: shc@xxxxxxxxxxxxxxxxx
To: c400-l@xxxxxxxxxxxx
Date: Tue, 13 Jul 2010 09:13:18 +1000
Subject: Re: [C400-L] keyed user queue


On 13/07/2010, at 7:29 AM, Victor Gonzalez wrote:

I need to make an application that use keyed user
queue. All examples in ibm site are with FIFO user queue.
I was
wondering if anyone in this mailing list have a simple example on
how to
use user queue with key, or any documentation where i can read in
detail about the api for user queue ( i already checked ibm site )

You didn't look very hard then. See the Information Centre:

Programming->APIs by category->Objects->User Queue APIs->Using User
Queue APIs

This page says you need to use MI instructions to access the queue.
The "batch machine" example on this page shows that MI instructions
ENQ and DEQ (or rather the C function interfaces--enq() and deq() are
used). Knowing that these are MI instructions might prompt you to
look
in the:

Programming->Machine interface programming->Machine interface
instructions->i5/OS machine interface

where you will find documentation for the MI instructions. Also, the
ILE C/C++ MI Library Reference (SC09-2418), which hasn't been updated
in over a decade, provides documentation for the C function
interfaces
to MI. Note that they are really ILE interfaces and can be called
from
any ILE language that supports the necessary data types.

The MI Library Reference lists the C header files for each function.
You will need to use the header file and the MI instruction
documentation to determine appropriate values for keyed operations.
These are found in the QSYSINC library if the optional System
Openness
Includes have been installed on your system.

Essentially, create the user queue via QUSCRTUQ API specifying
suitable key length and message size. Then in your program allocate
sufficient space to a pointer of type _ENQ_Msg_Prefix_T. Populate the
Msg_Len field with the length of the text address by parameter 2,
populate the Msg array with the key value, then invoke enq passing a
resolved system pointer to the queue object, the prefix pointer (i.e.,
key structure), and the address of the message text. Fetching a queue
entry is essentially the reverse process; allocate sufficient space
to
a pointer of type _DEQ_Msg_Prefix_T. Populate wait time fields, the
search relationship field (EQ, GT, etc.), and the search key and pass
it to deq().

Pseudo-code:

Declare system pointer Q
Declare pointer E of type _ENQ_Msg_Prefix_T
Declare pointer D of type _DEQ_Msg_Prefix_T
Declare field T of type char large enough for message text
Declare field rc of type integer

/* Create a keyed user queue with key-length 32 bytes and message
length 500 bytes */
/* Initially has room for 100 messages and will expand by 10
messages as it fills up */
CALL QUSCRTUQ( "QUEUENAME LIBNAME ", "EXT ATTR ", "K", 32, 500,
100, 10, "*USE ", "Description")

set Q to resolved address of user queue object
allocate space for E: 4-byte length plus key size
set Msg_Len field in E to length of message text
set Msg field in E to key value
set T to message text
/* invoke MI enq instruction to add message to queue */
rc = enq( Q, E, T )
if rc is 0 then handle error

allocate space for D: room for two 8-byte time stamps, integer, bit
fields, plus twice key size
set Key_Relation field in D to _DEQ_GEQ (or whatever search
relationship you want)
set Key field in D to key search criteria--partial key is allowed
either
set Wait_Time in D to MI time-stamp of time at which to end
waiting
for message
or
set Wait_Forever field in D to true
/* invoke MI deq instruction to fetch message from queue */
rc = deq( D, T, Q );
if rc is 1 then process message in T

etc. etc. etc.



This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].