📄 function.sammessage-header.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>The header properties of the message.</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.sam.html">SAM Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.snmp.html">SNMP</a></div> <div class="up"><a href="ref.sam.html">SAM Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.sammessage-header" class="refentry"> <div class="refnamediv"> <h1 class="refname">SAMMessage->header</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">SAMMessage->header</span> — <span class="dc-title"> The header properties of the message. </span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="classsynopsis"> <div class="ooclass"><b class="classname">SAMMessage</b></div> <div class="fieldsynopsis"><span class="type">object</span> <var class="varname">$header</var>;</div> </div> <p class="para"> The <i>header</i> property is a container for any system or user properties that area associated with the message. </p> <p class="para"> Properties may be assigned by the sender of a message to control the way the messaging systems handles it or may be assigned by the messaging system itself to tell the recipient extra information about the message or the way in which it has been handled. </p> <p class="para"> Some properties are understood by SAM in which case constants have been defined for them. The majority of properties however are ignored by the SAM implementation and simply passed through to the underlying messaging systems allowing the application to use messaging specific property names or to define its own "user" properties. </p> <p class="para"> The SAM defined properties are as follows: <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Property name</th> <th colspan="1">Possible values</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_MESSAGEID</td> <td colspan="1" rowspan="1" align="left"> When a message is received this field contains the unique identifier of the message as allocated by the underlying messaging system. When sending a message this field is ignored. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_REPLY_TO</td> <td colspan="1" rowspan="1" align="left"> A string providing the identity of the queue on to which responses to this message should be posted. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_TYPE</td> <td colspan="1" rowspan="1" align="left"> <p class="para"> An indication of the type of message to be sent. The value may be <b><tt>SAM_TEXT</tt></b> indicating the contents of the message body is a text string, or <b><tt>SAM_BYTES</tt></b> indicating the contents of the message body are some application defined format. </p> <p class="para"> The way in which this property is used may depend on the underlying messaging server. For instance a messaging server that supports the JMS (Java Message Service) specification may interpret this value and send messages of type "jms_text" and "jms_bytes". In addition, if the SAM_TYPE property is set to <b><tt>SAM_TEXT</tt></b> the data provided for the message body is expected to be a UTF8 encoded string. </p> </td> </tr> </tbody> </colgroup> </table> </p> <p class="para"> When setting the values of properties it is often useful to give a hint as to the format in which the property should be delivered to the messaging system. By default property values are delivered as text and the following simple syntax may be used to set a value: </p> <p class="para"> <div class="example"> <p><b>Example #1 Setting a text format property using the default syntax</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$msg </span><span style="color: #007700">= new </span><span style="color: #0000BB">SAMMessage</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myPropertyName </span><span style="color: #007700">= </span><span style="color: #DD0000">'textData'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> If it is desired to pass type information an alternative syntax may be used where the value and the type hint are passed in an associative array: </p> <p class="para"> <div class="example"> <p><b>Example #2 Setting a text format property using a type hint</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$msg </span><span style="color: #007700">= new </span><span style="color: #0000BB">SAMMessage</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myPropertyName </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'textData'</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_STRING</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> When passing a type hint the type entry should be one of the SAM defined constant values as defined by the following table: <table class="informaltable"> <colgroup>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -