Data Queue Methods

CrtDataQGetSPLList

CrtDataQGetSPLList ($DataQName, $DataQLib, $MaxLength, $Sequence, $KeyLength, $Authority, $QSizeMaxNumEntries, $ QSizeInitNumEntries) - Creates a Data Queue object.

Arguments

Value

Description

$DataQName

Data Queue name

$DataQLib

Data Queue library name

$MaxLength

128 - default

Data Queue length

$Sequence

  • *LIFO - default

  • *FIFO

  • *KEYED

Sequence type

$KeyLength

0 - default

Key length

Applicable if $Sequence=’*KEYED’

$Authority

  • *LIBCRTAUT - default

  • *CHANGE

  • *ALL

  • *USE

  • *EXCLUDE

Data Queue object authority

$QSizeMaxNumEntries

  • 32999 - default

  • *MAX16MB

  • *MAX2GB

Queue maximum number of entries

$QSizeInitNumEntries

16 - default

Initial number of entries

Sample Code

Usage Example

$DQ->CreateDataQ('TESTDQ', $test_lib, 200, '*KEYED', 15, '*CHANGE', 100, 20 )

CrtDataQ

CrtDataQ ($DataQName, $DataQLib, $MaxLength, $Sequence, $KeyLength, $Authority, $QSizeMaxNumEntries, $ QSizeInitNumEntries) - Creates a Data Queue object.

Arguments

Value

Description

$DataQName

Data Queue name

$DataQLib

Data Queue library name

$MaxLength

128 - default

Data Queue length

$Sequence

  • *LIFO - default

  • *FIFO

  • *KEYED

Sequence type

$KeyLength

0 - default

Key length

Applicable if $Sequence=’*KEYED’

$Authority

  • *LIBCRTAUT - default

  • *CHANGE

  • *ALL

  • *USE

  • *EXCLUDE

Data Queue object authority

$QSizeMaxNumEntries

  • 32999 - default

  • *MAX16MB

  • *MAX2GB

Queue maximum number of entries

$QSizeInitNumEntries

16 - default

Initial number of entries

Sample Code

Usage Example

$DQ->CreateDataQ('TESTDQ', ‘TESTLIB’, 200, '*KEYED', 15, '*CHANGE', 100, 20 )

DeleteDQ

DeleteDQ ($DataQName, $DataQLib) - Delete a Data Queue object.

Arguments

Value

Description

$DataQName

Data Queue name

$DataQLib

Data Queue library name

Sample Code

Usage Example

$DQ->DeleteDQ('TESTDQ', ‘TESTLIB’)

ReceieveDataQueue

ReceieveDataQueue($WaitTime, $KeyOrder, $KeyLength , $KeyData ', $WithRemoveMsg ) - Write a message to a Data Queue.

Arguments

Value

Description

$WaitTime

The amount of time to wait if no entries exist on the Data Queue.

  • < 0 - Waits forever.
  • 0 - Continue processing immediately. If no entry exists, the call completes immediately with the length of data parameter set to zero.
  • > 0 - The number of seconds to wait. The maximum is 99999 which allows a wait time of approximately 28 hours.

$KeyOrder

The comparison criteria between the keys of messages on the Data Queue and the key data parameter. When the system searches for the requested key, the entries are searched in ascending order from the lowest value key to the highest value key until a match is found. If there are entries with duplicate keys, the entry that was put on the queue first is received.

Valid values are:

  • GT Greater than
  • LT Less than
  • NE Not equal
  • EQ Equal
  • GE Greater than or equal
  • LE Less than or equal

This parameter is ignored if the length of key data is zero. A value of blanks is recommended if the length of key data is zero.

$KeyLength

The length of the key data parameter. If this parameter is specified, it must be zero for nonkeyed Data Queues. For keyed Data Queues it must be equal to the length specified on the KEYLEN parameter on the Create Data Queue (CreateDataQ) method.

$KeyData

$WithRemoveMsg

‘N’- default

Whether the message is to be removed from the Data Queue when it is received.

Sample Code

Usage Example

$data = $DQ->ReceieveDataQueue(0, 'GE', 15, $data, 'N')

SendDataQueue

SendDataQueue($DataLen, $Data, $KeyLength, $KeyData) - Read a message from a Data Queue.

Arguments

Value

Description

$DataLen

The length of the message data. The minimum length is 8 bytes.

$Data

The message data

$KeyLength

Key length

$KeyData

Key value

Sample Code

Usage Example

$DQ->SendDataQueue(25.0, $message, 15.0, $key)

ClearDQ

ClearDQ($KeyOrder, $KeyLength, $KeyData) - Clear a Data Queue object.

Arguments

Value

Description

$KeyOrder

The comparison criteria between the keys of messages on the Data Queue and the key data parameter. When the system searches for the requested key, the entries are searched in ascending order from the lowest value key to the highest value key until a match is found. If there are entries with duplicate keys, the entry that was put on the queue first is received.

Valid values are:

  • GT Greater than
  • LT Less than
  • NE Not equal
  • EQ Equal
  • GE Greater than or equal
  • LE Less than or equal

This parameter is ignored if the length of key data is zero. A value of blanks is recommended if the length of key data is zero.

$KeyLength

Key length

$KeyData

Key value

Sample Code

Usage Example

$DQ->ClearDQ( ‘EQ’, 15.0, $key)

A PHP Script That Shows the Usage of All Data Queue Methods

Usage Example

<?php 
echo 'Create/Write/Read/Delete Data Queue object';

include_once 'authorization.php';
include_once '../API/iToolkitService.php';
include_once 'helpshow.php';

/* Work with *KEYED Data Queue */

$test_lib = "QGPL";
$ToolkitSrvObj = ToolkitService::getInstance($db, $user, $pass);
$DQ = new DataQueue($ToolkitSrvObj);
$DQ->SetDataQName('TESTDQ', $test_lib);
try {
$DQ->DeleteDQ();
}
catch (Exception $e) {
//echo "Data Queue does not exist".$e->getMessage();
}
try {
$DQ->CreateDataQ('TESTDQ', $test_lib, 200, '*KEYED', 15, '*CHANGE', 100, 20 );
}
catch (Exception $e) {
}

/* Write some data into the Queue*/
/* prepare array of keys + values*/
for ($i = 0; $i< 10; $i++){
$key = 'key'.$i;
$value = 'Value inserted for '.'key'.$i;
$DQKeys[] = $key;
$DQ->SendDataQueue( 25.0, $value, 15.0, $key);
}

foreach($DQKeys as $key)
{
$data = $DQ->ReceieveDataQueue(0, 'GE', 15, $key, 'N');
if($data['datalen']) $QueueData[$key]= $data['datavalue'];
else
$QueueData[$key]= 'Read failed';
}

if(isset($QueueData))
showTable($QueueData);
else
echo "Test failed.";
$DQ->DeleteDQ();
/* Do not use the disconnect() function for "state full" connection */
$ToolkitSrvObj->disconnect();
?>