Data queues

The DataQueue classes allow the Java™ program to interact with server data queues.

Data queues on iSeries™ servers have the following characteristics:

The data queue classes provide a complete set of interfaces for accessing server data queues from your Java program. It is an excellent way to communicate between Java programs and programs on the server that are written in any programming language.

A required parameter of each data queue object is the AS400 object that represents the server that has the data queue or where the data queue is to be created.

Using the data queue classes causes the AS400 object to connect to the server. See managing connections for information about managing connections.

Each data queue object requires the integrated file system path name of the data queue. The type for the data queue is DTAQ. See integrated file system path names for more information.

Sequential and keyed data queues

The data queue classes support the following data queues:

Methods common to both types of queues are in the BaseDataQueue class. The DataQueue class extends the BaseDataQueue class in order to complete the implementation of sequential data queues. The BaseDataQueue class is extended by the KeyedDataQueue class to complete the implementation of keyed data queues.

When data is read from a data queue, the data is placed in a DataQueueEntry object. This object holds the data for both keyed and sequential data queues. Additional data available when reading from a keyed data queue is placed in a KeyedDataQueueEntry object that extends the DataQueueEntry class.

The data queue classes do not alter data that is written to or is read from the server data queue. The Java program must correctly format the data. The data conversion classes provide methods for converting data.

Example: Using DataQueue and DataQueueEntry

The following example creates a DataQueue object, reads data from the DataQueueEntry object, and then disconnects from the system.
Note: Read the Code example disclaimer for important legal information.
     // Create an AS400 object
     AS400 sys = new AS400("mySystem.myCompany.com");

     // Create the DataQueue object
     DataQueue dq = new DataQueue(sys, "/QSYS.LIB/MYLIB.LIB/MYQUEUE.DTAQ");

     // read data from the queue
     DataQueueEntry dqData = dq.read();

     // get the data out of the DataQueueEntry object.
     byte[] data = dqData.getData();

     // ... process the data

     // Disconnect since I am done using data queues
     sys.disconnectService(AS400.DATAQUEUE);