
Chapter 5: Real Time Data Functions
msgpublish
Description
Provides
a SQL interface to publish messages to topics.
Syntax
msgpublish_call::=msgpublish
(message_body, subscription_name [options_and_properties)
options_and_properties::=
[option_clause] [properties_clause]
option_clause::=[,] option option_string]
properties_clause::=[,]message property option_string
message_body::=
scalar_expression
| (select_for_xml)
Parameters
- message_body
The message you are sending. The message body can
contain any string of characters. It can be binary data, character
data, or SQLX data.
- subscription_name
Name of the subscription to which you are publishing
messages.
- option_string
The general format of an option_string is
specified in the section option_string—general format.
The options you can specify for msgsend are
in Table 5-1:
Table 5-5: Options for msgpublish
Option
|
Value
|
Default
|
Comments
|
schema
|
no
yes
“user_schema”
|
no
|
user_schema is
a user-supplied schema describing the message_body.
‘no’ means that no schema is generated
and sent out as part of the message.
‘yes’ means that Adaptive Server
generates an XML schema for the message. ‘yes’ is
only meaningful in a message_body that
uses the select_for_xml parameter. select_for_xml generates
a SQLX-formatted representation of the SQL result set. The generated
XML schema is a SQLX-formatted schema that describes the result
set document.
The schema is included in the message as ASE_MSGBODY_SCHEMA
property.
|
type
|
text | bytes
|
text
|
The message type to send.
|
- option_string
The general format of an option_string is
specified in the section option_string—general format.
The options you can specify for msgpublish are
in Table 5-5.
- properties_clause
Is either an option_string or
one of the options listed in Table 5-6. The options described in Table 5-6 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 5-2, it is set as
a property in the message properties of the message sent.
Table 5-6: Option values for properties of msgpublish
Option
|
Values
|
Default
|
Disposition
|
Comments
|
mode
|
persistent or nonpersistent
|
persistent
|
header
|
If the mode is persistent, the message
is backed by the JMS provider, using stable storage. If the messaging
provider crashes before the message can be consumed, the message
is lost, unless mode is set to persistent.
If the mode is nonpersistent, and the messaging providercrashes,
you may lose a message before it reaches the desired destination.
|
ttl
|
0 – (263-1)
|
0
|
header
|
ttl refers to time-to-live
on the messaging bus. Adaptive Server is not affected by this.
Expiry information, which is the duration of time during which
the message is valid, in milliseconds. For instance, 60 means that
the life of the message is 60 milliseconds.
A value of 0 means that the message does not expire.
|
priority
|
1 to 10
|
4
|
header
|
The behavior of priority is controlled
by the underlying message bus. The values mentioned here apply to
TIBCO_JMS.
Priorities from 0 to 4 are normal; priorities from 5 to 9
are expedited.
|
correlation
|
string
|
none
|
header
|
Client applications set correlation IDs
to link messages together. Adaptive Server sets the correlation
ID the application specifies.
|
replyqueue
replytopic
|
A string containing a queue_name
A string containing a topic_name
|
none
none
|
header
header
|
The value of queue_name or topic_name must
be syb_temp. The type of the temporary destination,
queue or topic, depends on whether you specify replyqueue or replytopic. Only
the option listed last is used. Adaptive Server creates a temporary
destination and sends information related to the newly created temporary
destination as a part of the header information.
|
- 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
A select expression that specifies
a for xml
clause.
Examples
Example 1
To publish messages, a subscription must be defined
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’
Example 2
Then the client server can publish a message to a
specified subscription:
select msgpublish
(’Sending order’, ’subscription_1’,
MESSAGE PROPERTY ’Supplier=12345’)
Usage
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’
Copyright © 2004. Sybase Inc. All rights reserved.
|
|
View this book as PDF 