MQSend() function

The MQSend() function puts the message into the WMQ queue.

Syntax


1  MQSEND (?  service_name ,?  policy_name ,  msg_data?  , correl_id  )(1)
Notes:
  • 1 See the Usage section for information about argument interpretation.
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.
msg_data
Required parameter. A string containing the data to be sent by WMQ. The maximum size of the string is defined by the LVARCHAR data type. If msg_data is NULL, it sends a zero-length message to the queue.
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 MQSend() function puts the data contained in msg_data into the WMQ location specified by service_name, using the quality of policy name defined by policy_name. If correl_id is specified, then the message is sent with a correlation identifier. If correl_id is not specified, then no correlation ID is sent with the message.

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

arg2 = msg_data

MQSend(arg1, arg2, arg3) arg1 = service_name

arg2 = policy_name

arg3 = msg_data

MQSend(arg1, arg2, arg3, arg4) arg1 = service_name

arg2 = policy_name

arg3 = msg_data

arg4 = correl_id

Return codes

1
The operation was successful.
0 or Error
The operation was unsuccessful.

Examples

Example 1
EXECUTE FUNCTION MQSend('Testing 123')
This example sends the message to the WMQ with the following parameters:
  • service_name: default service name
  • policy_name: default policy
  • msg_data: "Testing 123"
  • correl_id: none
Example 2
begin;
EXECUTE FUNCTION MQSend('MYSERVICE','Testing 901');
commit;
This example sends the message to the WMQ with the following parameters:
  • service_name: "MYSERVICE"
  • policy_name: default policy
  • msg_data: "Testing 901"
  • correl_id: none
Example 3
begin;
EXECUTE FUNCTION MQSend('MYSERVICE','MYPOLICY','Testing 345');
commit;
This example sends the message to the WMQ with the following parameters:
  • service_name: "MYSERVICE"
  • policy_name: "MYPOLICY"
  • msg_data: "Testing 345"
  • correl_id: none
Example 4
begin;
EXECUTE FUNCTION MQSend('MYSERVICE','MYPOLICY','Testing 678','TEST3');
commit;
This example sends the message to the WMQ with the following parameters:
  • service_name: "MYSERVICE"
  • policy_name: "MYPOLICY"
  • msg_data: "Testing 678"
  • correl_id: "TEST3"