File: SAM-Message-header.xml

package info (click to toggle)
php-doc 20100521-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 59,992 kB
  • ctags: 4,085
  • sloc: xml: 796,833; php: 21,338; cpp: 500; sh: 117; makefile: 58; awk: 28
file content (297 lines) | stat: -rw-r--r-- 9,760 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 297028 $ -->
<refentry xml:id='function.sammessage-header' xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>SAMMessage->header</refname>
  <refpurpose>
   The header properties of the message.
  </refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <classsynopsis>
   <ooclass><classname>SAMMessage</classname></ooclass>
   <fieldsynopsis><type>object</type><varname>header</varname></fieldsynopsis>
  </classsynopsis>
  <para>
   The <literal>header</literal> property is a container for any system or
   user properties that area associated with the message.
  </para>
  <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.
  </para>
  <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.
  </para>
  <para>
   The SAM defined properties are as follows:
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>Property name</entry>
       <entry>Possible values</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry><constant>SAM_MESSAGEID</constant></entry>
       <entry>
        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.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_REPLY_TO</constant></entry>
       <entry>
        A string providing the identity of the queue on to which
        responses to this message should be posted.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_TYPE</constant></entry>
       <entry>
        <para>
         An indication of the type of message to be sent. The value may be
         <constant>SAM_TEXT</constant> indicating the contents of the
         message body is a text string, or <constant>SAM_BYTES</constant>
         indicating the contents of the message body are some application
         defined format.
        </para>
        <para>
         The way in which this property is used may depend on the underlying
         messaging server. For instance a messaging server that supports the
         <literal>JMS (Java Message Service)</literal> specification may
         interpret this value and send messages of type "<literal>jms_text</literal>"
         and "<literal>jms_bytes</literal>". In addition, if the
         <constant>SAM_TYPE</constant> property is set to <constant>SAM_TEXT</constant>
         the data provided for the message body is expected to be a UTF8 encoded
         string.
        </para>
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
  <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:
  </para>
  <para>
   <example>
    <title>Setting a text format property using the default syntax</title>
    <programlisting role="php">
<![CDATA[
<?php
$msg = new SAMMessage();

$msg->header->myPropertyName = 'textData';
?>
]]>
    </programlisting>
   </example>
  </para>
  <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:
  </para>
  <para>
   <example>
    <title>Setting a text format property using a type hint</title>
    <programlisting role="php">
<![CDATA[
<?php
$msg = new SAMMessage();

$msg->header->myPropertyName = array('textData', SAM_STRING);
?>
]]>
    </programlisting>
   </example>
  </para>
  <para>
   When passing a type hint the type entry should be one of the SAM defined
   constant values as defined by the following table:
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>Constant</entry>
       <entry>Type description</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry><constant>SAM_BOOLEAN</constant></entry>
       <entry>
        Any value passed will be interpreted as logical true or false. 
        If the value cannot be interpreted as a PHP boolean value the value
        passed to the messaging system is undefined.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_BYTE</constant></entry>
       <entry>
        An 8-bit signed integer value. SAM will attempt to convert the
        property value specified into a single byte value to pass to the
        messaging system. If a string value is passed an attempt will be
        made to interpret the string as a numeric value. If the numeric
        value cannot be expressed as an 8-bit signed binary value data may
        be lost in the conversion.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_DOUBLE</constant></entry>
       <entry>
        A long floating point value. SAM will attempt to convert the
        property value specified into a floating point value with 15 digits
        of precision. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the passed value cannot
        be expressed as a 15 digit floating point value data may be lost in
        the conversion.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_FLOAT</constant></entry>
       <entry>
        A short floating point value. SAM will attempt to convert the
        property value specified into a floating point value with 7 digits of
        precision. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the passed value cannot
        be expressed as a 7 digit floating point value data may be lost in
        the conversion.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_INT</constant></entry>
       <entry>
        An 32-bit signed integer value. SAM will attempt to convert the
        property value specified into a 32-bit value to pass to the messaging
        system. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the numeric value cannot
        be expressed as an 32-bit signed binary value data may be lost in the
        conversion.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_LONG</constant></entry>
       <entry>
        An 64-bit signed integer value. SAM will attempt to convert the
        property value specified into a 64-bit value to pass to the messaging
        system. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the numeric value cannot
        be expressed as an 64-bit signed binary value data may be lost in the
        conversion.
       </entry>
      </row>
      <row>
       <entry><constant>SAM_STRING</constant></entry>
       <entry>
        SAM will interpret the property value specified as a string and pass
        it to the messaging system accordingly.
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Setting properties as the sender of a message</title>
    <programlisting role="php">
<![CDATA[
<?php
$msg = new SAMMessage('This is a test message');

// defining SAM specific properties...
$msg->header->SAM_REPLY_TO = 'queue://test/replyQueue';

// defining arbitrary properties...
//
// a default string property
$msg->header->myStringProp1 = 'a string property';
// a string property with a type hint
$msg->header->myStringProp2 = array('another string property', SAM_STRING);

// a boolean property
$msg->header->myBoolProp = array(FALSE, SAM_BOOL);

// numeric format properties
$msg->header->myIntProp = array(32768, SAM_INT);
$msg->header->myLongProp = array(9876543, SAM_LONG);
$msg->header->myByteProp1 = array(123, SAM_BYTE);
$msg->header->myByteProp2 = array('12', SAM_BYTE);
$msg->header->myFloatProp = array(3.141592, SAM_FLOAT);
$msg->header->myDoubleProp = array(3.14159265358979, SAM_DOUBLE);
?>
]]>
    </programlisting>
   </example>
  </para>
  <para>
   <example>
    <title>Retreiving property values from a message</title>
    <programlisting role="php">
<![CDATA[
<?php

// accessing an application specific property
$intProp = $msg->header->MyIntProp;

// accessing a messaging system specific property
$encoding = $msg->header->JMS_IBM_Msgtype;

?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><xref linkend="function.sammessage-body" /></member>
   </simplelist>
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->