The message type is the first of the service broker specific objects. The message type defines the name of the message, and performs any validation that the service broker needs to do on the contents of the message prior to sending the message. If the message is being sent to another database (on the same server or a different server) then the message type must exist on both databases.
Validation can be one of four options.
- None (My personal favorate especially for sample code)
- Valid_XML With Schema Collection
1 and 2 are pretty straight forward. None = No validation is done. Empty = The message must be empty. Well_Formed_XML requires that the XML be a valid XML document. The fourth option requires that not only the XML be valid, but that it fits within a pre-existing XML schema collection (an XSD which has been loaded into the SQL Server).
The syntax to create a Message Type is pretty basic.
CREATE MESSAGE TYPE [MessageTypeName]
VALIDATION = NONE
That’s it. If you need to change the schema use the AUTHORIZATION clause to set the owner of the object.
When using the validation of NONE it is up to the receiving code or application to verify that the data within the message exists and is valid.
DennyContact the Author | Contact DCAC