Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (Français) » QAnywhere » QAnywhere Reference » QAnywhere SQL API reference » Message management

 

ml_qa_listener_queue

Create a stored procedure named ml_qa_listener_queue (where queue is the name of a message queue) to receive messages asynchronously.

Parameters
Item Description Remarks
1 Message ID VARCHAR(128). You can obtain the message ID from the QAnywhere Listener.
Remarks
Note

This procedure is different from all the other QAnywhere stored procedures in that the stored procedure is not provided. If you create a stored procedure named ml_qa_listener_queue, where queue is a message queue, then it is used by QAnywhere.

Although messages can be received synchronously on a connection, it is often convenient to receive messages asynchronously. You can create a stored procedure that is called when a message has been queued on a particular address. The name of this procedure must be ml_qa_listener_queue, where queue is the message queue. When this procedure exists, the procedure is called whenever a message is queued on the given address.

This procedure is called from a separate connection. As long as a SQL error does not occur while this procedure is executing, the message is automatically acknowledged and committed.

Note

Do not commit or rollback within this procedure.

The queue name is part of the QAnywhere address. For more information, see QAnywhere message addresses.

See also
Example

The following example creates a procedure that is called whenever a message is queued on the address named executesql. In this example, the procedure assumes that the content of the message is a SQL statement that it can execute against the current database.

CREATE PROCEDURE ml_qa_listener_executesql(IN @msgid VARCHAR(128))
begin
 DECLARE @execstr LONG VARCHAR;
 SET @execstr = ml_qa_gettextcontent( @msgid );
 EXECUTE IMMEDIATE @execstr;
end