PDA

View Full Version : DATA Queue



amar_mohite
February 14th, 2006, 01:17 PM
Can we see all the entries of DATA Queue without removing it from that DATA queue? If yes how?Which API or command can we use?

Sbp0718
February 14th, 2006, 01:40 PM
A data queue is a first in first out data stack.

The following API will allow you to read a data queue without removing the entry.

Retrieve Data Queue Message (QMHRDQM) retrieves an entry from a data queue without removing the entry.

Here is a link to get the V5R2 version of the API

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm

amar_mohite
February 14th, 2006, 01:46 PM
Thanks for

amar_mohite
February 14th, 2006, 01:47 PM
Thanks for this valuable information

Pete
February 15th, 2006, 11:42 AM
You can also use the Qshell utility 'dataq'. It will read, write, or clear a dataq.

If you want to display dataq contents (actually, it is uses the 'r' -read switch with the 'p' -peek switch) to your screen (aka STDOUT) use:



QSH
dataq -rlp /qsys.lib/coalib.lib/statement.dtaq


To dump dataq contents to a file, use:


PGM
DCL VAR(&QSHCMD) TYPE(*CHAR) LEN(100)
OVRDBF FILE(STDOUT) TOFILE(YOURLIB/YOURFILE)
CHGVAR VAR(&QSHCMD) VALUE('dataq -rlp +
/qsys.lib/yourlib.lib/yourdataq.dtaq')
QSH CMD(&QSHCMD)
ENDPGM


Pete

jimmyoctane
February 15th, 2006, 11:54 AM
Hey pete does it remove the entry when reading ?

Pete
February 15th, 2006, 12:03 PM
No sir Mr. Octane. The 'p' switch is for peek mode, which is read only.

More info is here:


Follow link to IBM (http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzahz/utility.htm)


Pete

jimmyoctane
February 15th, 2006, 12:08 PM
Nice ....... R u dating anyone?
Like cowboy movies???



dataq - Send or receive messages from OS/400 data queue
Synopsis

dataq -c queue

dataq -r [-lp] [-n number] [-t seconds] queue

dataq -w [-l] [-n number] queue [ data ... ]

Description

The dataq utility clears messages from a data queue, reads messages
from a data queue, or writes messages to a data queue.

In the first synopsis form, dataq clears all of the messages from the queue.

In the second synopsis form, dataq reads messages from the queue and
writes them to standard output. By default, it reads one message from the
queue. If no messages are available from the queue, dataq waits for a
message.

In the third synopsis form, dataq writes messages to the queue. If data is
specified, it is written as one message to the queue. Otherwise, each line
read from standard input is written as a message to the queue.

Options

-c
Clear all of the messages from the queue.
-l
When a relative path name is specified, use the library list to find the queue.
-n number
If the -r option is specified, read number messages from the queue.
If the -w option is specified, write number messages to the queue.
-p
Peek mode. When reading messages, the messages are left on the queue.
-r
Read messages from the queue.
-t seconds
When reading messages, exit if no messages have been received after
seconds seconds of waiting.
-w
Write messages from the queue.
Operands

The queue is the path name to a data queue. A data queue can only
exist in the QSYS.LIB file system.

Exit Status

0 when successful
>0 when unsuccessful




Take care
Jimmy

jimmyoctane
February 15th, 2006, 01:43 PM
Hey I know im a bit slow but how can i see all the entries in dataq rather than just the first one??

Pete
February 15th, 2006, 04:27 PM
I believe that is where you use the -n (number) switch.
I think the syntax would be 'dataq -rlp -n xx /qsys.lib/yourlib.lib/yourq.dtaq', where xx is how many entries you want.
I have never used it for multiple entries. I had set up a dataq on an output queue so that a spool file produced daily at 9:00 would be converted to a disk file, zipped and then FTPd to a 3rd party mailing firm. I never had more than one entry in the queue at a time.

Pete

jimmyoctane
February 15th, 2006, 04:34 PM
I know I tried this


PGM
DCL VAR(&QSHCMD) TYPE(*CHAR) LEN(100)
OVRDBF FILE(STDOUT) TOFILE(JAMIELIB/SOURCE) +
MBR(JACKEM)
CHGVAR VAR(&QSHCMD) VALUE('dataq -rlp -n05 +
/qsys.lib/jamielib.lib/test.dtaq')
QSH CMD(&QSHCMD)
ENDPGM




cause i know there are five entries but i get this


Test entry1-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry1-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry1-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry1-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry1-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000


All the same records # 1




PGM
DCL VAR(&QSHCMD) TYPE(*CHAR) LEN(100)
OVRDBF FILE(STDOUT) TOFILE(JAMIELIB/SOURCE) +
MBR(JACKEM)
CHGVAR VAR(&QSHCMD) VALUE('dataq -rl -n05 +
/qsys.lib/jamielib.lib/test.dtaq')
QSH CMD(&QSHCMD)
ENDPGM


here is what I get when I remove the peak.


Test entry1-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry2-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry3-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry4-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000
Test entry5-11.38.57 TEST JAMIELIB 0001-01-01-00.00.00. 000000


Its close but ???

jimmyoctane
February 15th, 2006, 05:04 PM
also see attached program I have tried with both QRCVDTAQ remove message = 'N' and QMHRDQM I have same issues when trying it this way???




**
d TimeStamp s Z
d IsOdate s D
d Count s 4 0
d Count2 s 4 0
d CmdString s 256
d CmdLength s 15 5
d Reply s 1
d Chr26 s 26
**
* The defined fields for the QRCVDTAQ
**
d DtaqName s 10A inz('TEST')
d DtaqLib s 10A inz('QTEMP')
d DtaqLen s 5P 0 inz(1000)
d Data s 40A
d WaitTime s 5P 0 inz(-1)
d KeyOrder s 2A
d KeyLen s 3P 0
d KeyData s 32766A
d SenderLen s 3P 0
d SenderInfo s 32766A
d RmvMsg s 10A inz('*YES')
d RcvVarSize s 5P 0
d ErrorCode s 32766A
*
d Receiver s 2322
d ReceiverLen s 4B 0 inz(2322)
d ReceiverFmt s 8 inz('RDQM0100')
d DataQName s 20 inz('TEST QTEMP')
d MessageSel s 272
d MessageSelLn s 4B 0 inz(32)
d MessageFmt s 8 inz('RDQS0200')
d Error s 4B 0 inz(0)
*
* constants
*
d Q c const('''')
*
**
** Delete the message queue
**
c eval cmdstring = 'DLTDTAQ QTEMP/TEST'
c eval cmdlength = %len(%trim(cmdstring))
*
c call(e) 'QCMDEXC'
c parm cmdstring
c parm cmdlength
**
** CRTDTAQ DTAQ(QTEMP/TEST) MAXLEN(1000) SEQ(*KEYED)
** KEYLEN(05) SENDERID(*YES)
**
c eval cmdstring = 'CRTDTAQ DTAQ(QTEMP/TEST) ' +
c 'MAXLEN(1000) SENDERID(*YES)' +
c ' TEXT(' + Q + 'test dataq'+ Q + ')'
c eval cmdlength = %len(%trim(cmdstring))
c call(e) 'QCMDEXC'
c parm cmdstring
c parm cmdlength
**
** Clear data queue
**
c call(e) 'QCLRDTAQ'
c parm DtaqName
c parm DtaqLib
**
c for Count = 1 to 5
**
c eval Data = 'Test entry' + %char(Count) +
c '-' + %char(%time())
**
c call(e) 'QSNDDTAQ'
c parm DtaqName Data queue name
c parm DtaqLib Data queue library
c parm DtaqLen Data queue length
c parm Data Queued data
c****> parm KeyLen Key length
c****> parm KeyData Key value
**
c endfor
**
c do 1
**
c call 'QRCVDTAQ'
c parm DtaqName Data queue name
c parm DtaqLib Data queue library
c parm DtaqLen Data queue length
c parm Data Queued data
c parm WaitTime Seconds to wait
c****> parm KeyOrder Key selection
c****> parm KeyLen Key length
c****> parm KeyData Key valueh
c****> parm SenderLen Senderninfo length
c****> parm SenderInfo Senderninfo
c****> parm RmvMsg RemovenMsg *NO or *YES
c****> parm RcvVarSize Sizelofgdata receiver
c****> parm ErrorCode Errorength
**
c data dsply reply
**
c enddo
**
c for Count = 1 to 5
c call 'QMHRDQM'
c parm Receiver Data queue name
c parm ReceiverLen Data queue library
c parm ReceiverFmt Data queue length
c parm DataQName Queued data
c parm MessageSel Seconds to wait
c parm MessageSelLn Seconds to wait
c parm MessageFmt Seconds to wait
c parm Error Seconds to wait
c endfor
**
c eval *INLR = *on
**

Pete
February 16th, 2006, 09:11 AM
Bad news, JimmyO. The lads in Rochester tell me that -p (peek mode) will only return one value. If the -n (number) switch is used in addition to the -p switch, it will return that one value n times. If the -p switch is removed, the -n switch will work properly. This is considered to be "working as designed".
They did indicate that the documentation could be better, so maybe by V6R4 the info center will be rewritten.......

Pete