Provides a SQL interface to publish messages to topics.
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)
is the message you are sending. The message body can contain any string of characters. It can be binary data, character data, or SQLX data.
is the name of the subscription to which you are publishing messages.
is the general format of the option name and an option_string, specified in the section option_string.
The options you can specify for msgsend are in Table 4-5.
is either an option_string or one of the options listed in the following tables. The options described in Table 4-5 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.
If you use a property not listed in Table 4-6, it is set as a property in the message properties of the message sent.
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.
is a select expression that specifies a for xml clause.
allows users to specify only header properties You see an error if you enter an unrecognized header property.
If a recognized header property is specified in both the message property and the message header clauses, the one in the message header clause takes precedence.
You get an error when you specify any unrecognized options in the option_clause.
All previously recognized header properties are accepted in the message header clause.
To publish messages, you must define a subscription on the server to which the client is connected:
sp_msgadmin 'register', 'subscription', 'subscription_1', 'my_ems_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')
Unrecognized options are ignored if you use message property. If you use message header for the msgsend or msgpublish functions, you see an error when you specify unrecognized options.
The subscription_name must have been specified in a call to:
sp_msgadmin 'register', 'subscription'
It should not be specified in a subsequent call to:
sp_msgadmin 'remove', 'subscription'
Table 4-5 lists the options you can specify for msgsend.
Table 4-6 lists the options and values for the properties_clause parameter. If you use a property not listed in Table 4-6, it is set as a property in the message properties of the message sent.
You must have messaging_role to run msgpublish.
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |