MQHasMessage() function

The MQHasMessage() function checks if a message is available from the WMQ.

Syntax


1  MQHasMessage (?  service_name?  , policy_name?  , correl_id  )
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

You can simulate event processing by using this function and other MQ functions to write custom procedures and run them inside the Scheduler at specified intervals.

The following table describes how the arguments for the MQHasMessage() function are interpreted.
Table 1. MQHasMessage() argument interpretation
Usage Argument interpretation
MQHasMessage() No arguments
MQHasMessage(arg1) arg1 = service_name
MQHasMessage(arg1, arg2) arg1 = service_name

arg2 = policy_name

MQHasMessage(arg1, arg2, arg3) arg1 = service_name

arg2 = policy_name

arg3 = correl_id

Return codes

1
One message or more than one message is present.
0
No Messages are available.
Error
The operation was unsuccessful.

Example

This following example reads the message with the following parameters:
  • service_name: "MYSERVICE"
  • policy_name: "MYPOLICY"
  • correl_id: "TESTS"
begin;
EXECUTE FUNCTION MQHasMessage('MYSERVICE','MYPOLICY', 'TESTS');
commit;