Data queues provide many benefits to PC developers and iSeries applications developers, including:
- They are a fast and efficient means of communication on the iSeries server.
- They have low system overhead and require very little setup.
- They are efficient because a single data queue can be used by a batch job to service several interactive jobs.
- The contents of a data queue message are free-format (fields are not required), providing flexibility that is not provided by other system objects.
- Access data queues through an iSeries API and through CL commands, which provides a straight-forward means of developing client/server applications.
There are three ways to designate the order of messages on a data queue:
- LIFO
- Last in, first out. The last message (newest) placed on the data queue will be the first message taken off of the queue.
- FIFO
- First in, first out. The first message (oldest) placed on the data queue will be the first message taken off of the queue.
- KEYED
- Each message on the data queue has a key associated with it. A message can be taken off of the queue only by requesting the key with which it is associated.
- CRTDTAQ
- Creates a data queue and stores it in a specified library
- DLTDTAQ
- Deletes the specified data queue from the system
OS/400 application programming interfaces:
- QSNDDTAQ
- Send a message (record) to the specified data queue
- QRCVDTAQ
- Read a message (record) to the specified data queue
- QCLRDTAQ
- Clear all messages from the specified data queue
CRTDTAQ Command allows you to create a data queue object. A data queue is identified on AS400 system by its type *DTAQ. This command allows you to create both local as well DDM data queue. Some of the command parameters are ...
- Name – This is the name of the data queue. It’s required parameter.
- Library – Default is user’s current library.
- Type – Default is standard (*STD). Created on local system. A DDM data queue is the same as a DDM file. It is a logical view of a data queue on another machine. A DDM data queue points to the *STD data queue on the other machine.
- Max Length –This is the maximum length of each entry. We generally keep it sufficient enough to accommodate any future changes.
- Auxiliary Storage –Default is *NO. This means any changes to data queue are not immediately written to the backup storage. *YES means changes are immediately written to the backup storage.
- Access Sequence – This is what we discussed earlier. Default is the most commonly used access sequence i.e *FIFO. Other valid values are *LIFO and *KEYED. If you select *KEYED, you are then prompted for the key length. Just as with a database file, the key length is the length of the data you are going to use as the key to the data queue.
- Size – This value restricts the maximum storage which can be allocated to a data queue. This can be a number like 100, *MAX16MB or *MAX2GB. With *max options, the system calculates how many max entries should be allowed.
Example:
CRTDTAQ DTAQ(MYLIB/@MYDATAQ) MAXLEN(256)
You can create a DDM data queue with the following command:
CRTDTAQ DTAQ(LOCALLIB/DDMDTAQ) TYPE(*DDM) RMTDTAQ(REMOTELIB/REMOTEDTAQ) RMTLOCNAME(SYSTEMB) TEXT('DDM data queue to access data queue on SYSTEMB')
DLTDTAQ command allows you to delete a data queue from a specific a specific library.
Example:
DLTDTAQ DTAQ(MYLIB/@MYDATAQ)
The Send Data Queue (QSNDDTAQ) API sends data to the specified data queue.
call 'QSNDDTAQ' parm '@MYDATAQ' dtaq_name parm '*LIBL' dtaq_lib parm 256 dtaq_len parm dtaq_data
The Receive Data Queue (QRCVDTAQ) API receives data from the specified data queue.
When more than one program has a receive pending on a data queue at one time, a data entry sent to the data queue is received by only one of the programs. The program with the highest run priority receives the entry. The next entry sent to the queue is given to the job with the next highest priority.
call 'QRCVDTAQ' parm '@MYDATAQ' @DQ_NAME parm '*LIBL' @DQ_Libr parm @DQ_Length parm @DQ_Data Parm -1 @Wait_Sec
Wait time less than ZERO mean infinite wait !
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.