msgpublish

Description

JMS only – provides a SQL interface to publish messages to topics.

Syntax

message_publish_call ::=
	msgpublish(message_body, subscription_name 
		[options_and_properties])
			options_and_properties ::= 
				[option_clause] [properties_clause] 
				[header_clause]
					option_clause ::= [,] option option_string
					header_clause ::= [,] message header
						option_string
					properties_clause ::= 
						[,] message property option_string
					message_body ::= scalar_expression |
							(select_for_xml)

Parameters

message_body

is the message you are sending. The message body can contain any string of characters, and can be binary data, character data, or SQLX data.

subscription_name

is the name of the subscription to which you are publishing messages.

option_clause

is the general format of the option name and an option_string, specified in the section on page §.

The options you can specify for msgsend are in Table 3-7.

properties_clause

is either an option_string or one of the options listed in the following tables. The options described in Table 3-7 and Table 3-8 are set as a property in the message header or message properties, as indicated in the disposition column of the table. The option value is the property value.

Property names are case-sensitive.

scalar_expression

If a message is a SQL scalar_expression, it can be of any datatype.

If the type option is not specified, the message type is text if the scalar_expression evaluates to a character datatype; otherwise, the message type is bytes.

If the datatype of the scalar_expression is not character, it is converted to varbinary using the normal SQL rules for implicit conversion. The binary value of the datatype is included in the message according to the byte ordering of the host machine.

select_for_xml

is a select expression that specifies a for xml clause.

header_clause

allows users to specify only header properties You see an error if you enter an unrecognized header property.

If you specify a recognized header property in both the message property and the message header clauses, the one in the message header clause takes precedence.

You see an error if you specify unrecognized options in the option_clause.

All previously recognized header properties are accepted in the message header clause.

Examples

Example 1

To publish messages, you must define a subscription on the server to which the client is connected:

sp_msgadmin 'register', 'subscription', 'subscription_1',
     'my_jms_provider?topic=topic.sample,user=user1,password=pwd',
     'Supplier=12345',null, 'durable1', 'client'

The client server can then publish a message to a specified subscription:

select msgpublish
     ('Sending order', 'subscription_1',
     MESSAGE PROPERTY 'Supplier=12345')

Usage

Permissions

You must have messaging_role to run msgpublish.