MQSEND

The MQSEND function sends a message to a specified MQSeries® location.

Read syntax diagramSkip visual syntax diagramMQSEND( send-service,service-policy, msg-data ,correl-id1 )
Notes:
  • 1 The correl-id cannot be specified unless a send-service and a service-policy are also specified.
The MQSEND function sends the message data that is contained in msg-data to the MQSeries location that is specified by send-service, using the quality-of-service policy that is defined in service-policy. The message is sent using the MQSeries built-in format MQFMT_STRING.
send-service
An expression that returns a value that is a built-in character string or graphic string data type that is not a LOB. The value of the expression must not be an empty string or a string with trailing blanks. The expression must have an actual length that is no greater than 48 bytes. The value of the expression must refer to a service point that is defined in the SYSIBM.MQSERVICE table. A service point is a logical end-point from where a message is sent or received. Service point definitions include the name of the MQSeries queue manager and queue. For more information about MQSeries Application Messaging, see SQL Programming.

If send-service is not specified or the null value, DB2®.DEFAULT.SERVICE is used.

service-policy
An expression that returns a value that is a built-in character string or graphic string data type that is not a LOB. The value of the expression must not be an empty string or a string with trailing blanks. The expression must have an actual length that is no greater than 48 bytes. The value of the expression must refer to a service policy that is defined in the SYSIBM.MQPOLICY table. A service policy specifies a set of quality-of-service options that are to be applied to this messaging operation. These options include message priority and message persistence. For more information about MQSeries Application Messaging, see SQL Programming.

If service-policy is not specified or the null value, DB2.DEFAULT.POLICY is used.

msg-data
An expression that returns a value that is a built-in character string data type. If the expression is a CLOB, the value must not be longer than 2 MB. Otherwise, the value must not be longer than 32000 bytes. The value of the expression is the message data that is to be sent via MQSeries. A null value, an empty string, and a fixed length string with trailing blanks are all considered valid values.
correl-id
An expression that returns a value that is a built-in character string or graphic string data type that is not a LOB. The expression must have an actual length that is no greater than 24 bytes. The value of the expression specifies the correlation identifier that is associated with this message. A correlation identifier is often specified in request-and-reply scenarios to associate requests with replies. For more information about MQSeries Application Messaging, see SQL Programming.

A fixed length string with trailing blanks is considered a valid value. However, when the correl-id is specified on another request such as MQRECEIVE, the identical correl-id must be specified to be recognized as a match. For example, specifying a value of 'test' for correl-id on MQSEND does not match a correl-id value of 'test ' (with trailing blanks) specified subsequently on an MQRECEIVE request.

If correl-id is not specified or is an empty string or the null value, a correlation identifier is not sent.

The result of the function is a varying-length string with a length attribute of 1. The result is nullable, even though a null value is never returned. The result is '1' if the function was successful or '0' if unsuccessful.

The CCSID of the result is the default SBCS CCSID at the current server.

Notes

Prerequisites: In order to use the MQSeries functions, IBM® MQSeries for IBM i must be installed, configured, and operational.

Example

  • This example sends the string "Testing 123" to the default service (DB2.DEFAULT.SERVICE), using the default policy (DB2.DEFAULT.POLICY), with no correlation identifier.
      SELECT MQSEND ('Testing 123')
       FROM SYSIBM.SYSDUMMY1
       
  • This example sends the string "Testing 345" to the service "MYSERVICE", using the policy "MYPOLICY", with no correlation identifier.
       SELECT MQSEND ('MYSERVICE','MYPOLICY','Testing 345')
        FROM SYSIBM.SYSDUMMY1
        
  • This example sends the string "Testing 678" to the service "MYSERVICE", using the policy "MYPOLICY", with correlation identifier "TEST3".
       SELECT MQSEND ('MYSERVICE','MYPOLICY','Testing 678','TEST3')
        FROM SYSIBM.SYSDUMMY1
        
  • This example sends the string "Testing 901" to the service "MYSERVICE", using the default policy (DB2.DEFAULT.POLICY), and no correlation identifier.
       SELECT MQSEND ('MYSERVICE','Testing 901')
        FROM SYSIBM.SYSDUMMY1