MQRead() function
The MQRead() function returns a message from WMQ without removing the message from the queue.
Syntax
- service_name
- Optional parameter. Refers to the value in the servicename column of the "informix".mqiservice table. If service_name is not specified, IDS.DEFAULT.SERVICE is used as the service. The maximum size of service_name is 48 bytes.
- policy_name
- Optional parameter. Refers to the value in the policyname column of the "informix".mqipolicy table. If policy_name is not specified, IDS.DEFAULT.POLICY is used as the policy. The maximum size of policy_name is 48 bytes.
- correl_id
- Optional parameter. A string containing a correlation identifier to be associated with this message. The correl_id is often specified in request and reply scenarios to associate requests with replies. The maximum size of correl_id is 24 bytes. If not specified, no correlation ID is added to the message.
Usage
The MQRead() function returns a message from the WMQ queue specified by service_name, using the quality of service policy defined in policy_name. This function does not remove the message from the queue associated with service_name. If correl_id is specified, then the first message with a matching correlation ID is returned. If correl_id is not specified, then the message at the head of the queue is returned. The result of the function is a string of type LVARCHAR. If no messages are returned, this function returns NULL. This function only reads committed messages.
Usage | Argument interpretation |
---|---|
MQRead() | No arguments |
MQRead(arg1) | arg1 = service_name |
MQRead(arg1, arg2) | arg1 = service_name arg2 = policy_name |
MQRead(arg1, arg2, arg3) | arg1 = service_name arg2 = policy_name arg3 = correl_id |
Return codes
- A string of type LVARCHAR
- The operation was successful.
- NULL
- No Messages are available.
- Error
- The operation was unsuccessful.
Examples
begin;
EXECUTE FUNCTION MQRead();
commit;
insert into my_order_table VALUES(MQRead());
- service_name: default service name
- policy_name: default policy name
- correl_id: None
begin;
EXECUTE FUNCTION MQRead('MYSERVICE');
rollback;
insert into my_order_table VALUES(MQRead('MYSERVICE'));
- service_name: "MYSERVICE"
- policy_name: default policy name
- correl_id: None
begin;
EXECUTE FUNCTION MQRead('MYSERVICE','MYPOLICY');
commit;
insert into my_order_table VALUES(MQRead('MYSERVICE', 'MYPOLICY'));
- service_name: "MYSERVICE"
- policy_name: "MYPOLICY"
- correl_id: None
begin;
EXECUTE FUNCTION MQRead('MYSERVICE','MYPOLICY', 'TESTS');
commit;
insert into my_order_table VALUES(MQRead('MYSERVICE', 'MYPOLICY', 'TESTS'));
- service_name: "MYSERVICE"
- policy_name: "MYPOLICY"
- correl_id: "TESTS"