Messages
Messages sent to and received from queues are represented by the SAMMessage object. The SAMMessage object encapsulates the body of the message (if one exists) and the header properties associated with the message. A SAMMessage object is either supplied as a parameter to a messaging operation or returned as a result.
Example #1 Creating a message with a simple text body
<?php
$msg = new SAMMessage('This is a simple text message');
?>
Messages may have header properties associated with them that provide control over the transport of the message or further information to the receiving application. By default message properties are delivered to the underlying messaging system as strings and in this case they may be set with the following simple syntax:
Example #2 Setting a text format property using the default syntax
<?php
$msg->header->myPropertyName = 'textData';
?>
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:
Example #3 Setting a property using a type hint
<?php
$msg->header->myPropertyName = array(3.14159, SAM_FLOAT);
?>
Properties may also be extracted from the header of a message.
Example #4 Retrieving a property from a message header
<?php
$myProperty = $msg->header->myPropertyName;
?>
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-sam.messages.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.