ml_qa_getmessagetimeout

Waits for the specified timeout period to return the message ID of the next message that is queued for the given address.

Parameters
Item Description Remarks
1 Address VARCHAR(128)
2 Timeout in milliseconds INTEGER
Return value

The message ID as VARCHAR(128).

Returns null if there is no queued message for this address within the timeout period.

Remarks

Use this stored procedure to check synchronously whether there is a message waiting for the specified QAnywhere message address. If you want a SQL procedure to be called asynchronously as soon as a message is available for a specified QAnywhere address, use the Listener.

The message corresponding to the returned message is not considered to be received until the current transaction is committed. Once the receive is committed, the message cannot be received again by this or any other QAnywhere API. Similarly, a rollback of the current transaction means that the message is not received, so subsequent calls to ml_qa_getmessage may return the same message ID.

The properties and content of the received message can be read by the various ml_qa_get stored procedures until a commit or rollback is executed on the current transaction. Once a commit or rollback is executed on the current transaction, the message data is no longer readable. Before committing, you should store any data you need from the message as tabular data or in SQL variables.

See also
Example

The following example outputs the content of all messages sent to the address myaddress to the database server messages window, and updates the database server messages window every 10 seconds if no message has been received:

begin
    declare @msgid varchar(128);
    loop
        set @msgid = ml_qa_getmessagetimeout( 'myaddress', 10000 );
        if @msgid is null then
            message 'waiting for a message...';
        else
            message 'a message with content ' || ml_qa_gettextcontent( @msgid ) || ' has been received';
        commit;
        end if;
    end loop;
end