Tib RV CPP Reference
Tib RV CPP Reference
C++ Reference
Software Release 8.3.0
July 2010
Important Information
SOME TIBCO SOFTWARE EMBEDS OR BUNDLES OTHER TIBCO SOFTWARE. USE OF SUCH EMBEDDED
OR BUNDLED TIBCO SOFTWARE IS SOLELY TO ENABLE THE FUNCTIONALITY (OR PROVIDE LIMITED
ADD-ON FUNCTIONALITY) OF THE LICENSED TIBCO SOFTWARE. THE EMBEDDED OR BUNDLED
SOFTWARE IS NOT LICENSED TO BE USED OR ACCESSED BY ANY OTHER TIBCO SOFTWARE OR FOR
ANY OTHER PURPOSE.
USE OF TIBCO SOFTWARE AND THIS DOCUMENT IS SUBJECT TO THE TERMS AND CONDITIONS OF A
LICENSE AGREEMENT FOUND IN EITHER A SEPARATELY EXECUTED SOFTWARE LICENSE
AGREEMENT, OR, IF THERE IS NO SUCH SEPARATE AGREEMENT, THE CLICKWRAP END USER
LICENSE AGREEMENT WHICH IS DISPLAYED DURING DOWNLOAD OR INSTALLATION OF THE
SOFTWARE (AND WHICH IS DUPLICATED IN TIBCO Rendezvous Installation) OR IF THERE IS NO SUCH
SOFTWARE LICENSE AGREEMENT OR CLICKWRAP END USER LICENSE AGREEMENT, THE LICENSE(S)
LOCATED IN THE “LICENSE” FILE(S) OF THE SOFTWARE. USE OF THIS DOCUMENT IS SUBJECT TO
THOSE TERMS AND CONDITIONS, AND YOUR USE HEREOF SHALL CONSTITUTE ACCEPTANCE OF
AND AN AGREEMENT TO BE BOUND BY THE SAME.
This document contains confidential information that is subject to U.S. and international copyright laws and
treaties. No part of this document may be reproduced in any form without the written authorization of TIBCO
Software Inc.
TIB, TIBCO, TIBCO Adapter, Predictive Business, Information Bus, The Power of Now, Rendezvous, TIBCO
Rendezvous and Messaging Appliance are either registered trademarks or trademarks of TIBCO Software Inc. in
the United States and/or other countries.
EJB, Java EE, J2EE, and all Java-based trademarks and logos are trademarks or registered trademarks of Sun
Microsystems, Inc. in the U.S. and other countries.
All other product and company names and marks mentioned in this document are the property of their
respective owners and are mentioned for identification purposes only.
THIS SOFTWARE MAY BE AVAILABLE ON MULTIPLE OPERATING SYSTEMS. HOWEVER, NOT ALL
OPERATING SYSTEM PLATFORMS FOR A SPECIFIC SOFTWARE VERSION ARE RELEASED AT THE SAME
TIME. SEE THE README.TXT FILE FOR THE AVAILABILITY OF THIS SOFTWARE VERSION ON A
SPECIFIC OPERATING SYSTEM PLATFORM.
THIS DOCUMENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS.
CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE
INCORPORATED IN NEW EDITIONS OF THIS DOCUMENT. TIBCO SOFTWARE INC. MAY MAKE
IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN
THIS DOCUMENT AT ANY TIME.
THE CONTENTS OF THIS DOCUMENT MAY BE MODIFIED AND/OR QUALIFIED, DIRECTLY OR
INDIRECTLY, BY OTHER DOCUMENTATION WHICH ACCOMPANIES THIS SOFTWARE, INCLUDING
BUT NOT LIMITED TO ANY RELEASE NOTES AND "READ ME" FILES.
Copyright © 1997–2010 TIBCO Software Inc. ALL RIGHTS RESERVED.
TIBCO Software Inc. Confidential Information
| iii
Contents
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Manual Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Related Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
TIBCO Product Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
How to Contact TIBCO Customer Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Chapter 1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Strings and Character Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Custom Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Chapter 4 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Validity of Data Extracted From Message Fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Scalar Snapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Pointer Snapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Deleting Snapshot References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Multiple Subscription Snapshots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Field Names and Field Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Finding a Field Instance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
TibrvMsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
TibrvMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
~TibrvMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
TibrvMsg::addField() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Add Scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Add Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Add Nested Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Add String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Add Opaque Byte Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Add XML Byte Sequence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Add DateTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
TibrvMsg::clearReferences() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
TibrvMsg::convertToString(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
TibrvMsg::createCopy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
TibrvMsg::detach(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
TibrvMsg::expand() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
TibrvMsg::getAsBytes() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
TibrvMsg::getAsBytesCopy() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
TibrvMsg::getByteSize() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
TibrvMsg::getCurrentTime(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
TibrvMsg::getField(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Get Scalar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Get Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Get Nested Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Get String. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Figures
Tables
Preface
This manual describes the TIBCO Rendezvous® API for C++ programmers. It is
part of the documentation set for Rendezvous Software Release 8.3.0.
Topics
Manual Organization
The organization of this book mirrors the underlying object structure of the
Rendezvous C++ API. Each chapter describes a group of closely related objects
and the methods that pertain to them.
Related Documentation
Typographical Conventions
Convention Use
TIBCO_HOME All TIBCO products are installed under the same directory. This directory is
TIBRV_HOME referenced in documentation as TIBCO_HOME. The value of TIBCO_HOME
depends on the operating system. For example, on Windows systems, the
default value is C:\tibco.
TIBCO Rendezvous installs into a version-specific directory inside TIBCO_HOME.
This directory is referenced in documentation as TIBRV_HOME. The value of
TIBRV_HOME depends on the operating system. For example on Windows
systems, the default value is C:\tibco\rv\8.3.0.
code font Code font identifies commands, code examples, filenames, pathnames, and
output displayed in a command window. For example:
Use MyCommand to start the foo process.
Convention Use
Key Key name separated by a plus sign indicate keys pressed simultaneously. For
combinations example: Ctrl+C.
Key names separated by a comma and space indicate keys pressed one after the
other. For example: Esc, Ctrl+Q.
The note icon indicates information that is of special interest or importance, for
example, an additional action required only in certain circumstances.
The tip icon indicates an idea that could be useful, for example, a way to apply
the information provided in the current section to achieve a specific result.
The warning icon indicates the potential for a damaging situation, for example,
data loss or corruption if certain steps are taken or not taken.
Convention Use
[ ] An optional item in a command or code syntax.
For example:
MyCommand [optional_parameter] required_parameter
| A logical OR that separates multiple items of which only one may be chosen.
For example, you can select only one of the following parameters:
MyCommand para1 | param2 | param3
Convention Use
{ } A logical group of items in a command. Other syntax notations may appear
within each logical group.
For example, the following command requires two parameters, which can be
either the pair param1 and param2, or the pair param3 and param4.
MyCommand {param1 param2} | {param3 param4}
In the next example, the command requires two parameters. The first parameter
can be either param1 or param2 and the second can be either param3 or param4:
MyCommand {param1 | param2} {param3 | param4}
In the next example, the command can accept either two or three parameters.
The first parameter must be param1. You can optionally include param2 as the
second parameter. And the last parameter is either param3 or param4.
MyCommand param1 [param2] {param3 | param4}
For comments or problems with this manual or the software it addresses, please
contact TIBCO Support as follows.
• For an overview of TIBCO Support, and information about getting started
with TIBCO Product Support, visit this site:
http://www.tibco.com/services/support
• If you already have a valid maintenance or support contract, visit this site:
http://support.tibco.com
Entry to this site requires a username and password. If you do not have a
username, you can request one.
Chapter 1 Concepts
This chapter presents concepts specific to the TIBCO Rendezvous® C++ language
interface. For concepts that pertain to Rendezvous software in general, see the
book TIBCO Rendezvous Concepts.
Topics
• Implementation, page 2
• Strings and Character Encodings, page 3
• Custom Datatypes, page 4
Implementation
The Rendezvous C++ API consists of a thin wrapper around the C API.
It features a lightweight object model, in which C++ objects refer to C objects
using a pointer or handle.
In general, C++ constructors declare typed variables and create hollow objects. In
contrast, create methods make hollow objects operational, by creating a
corresponding C object, and storing its handle in the C++ object.
Similarly, C++ destroy methods destroy the corresponding C object—however,
although they invalidate the C++ object, they do not free its storage. In contrast,
C++ destructors first call the corresponding destroy method, and then destroy
the C++ object, reclaiming its storage.
Data Objects
Data objects (messages, message fields, and datetime objects) present exceptions
to these rules. C++ data objects have constructors and destructors, but not create
and destroy methods.
Message constructors declare typed variables, but do not allocate storage; the first
operation on a message variable creates a C++ object.
Datetime and field objects are identical to the corresponding C structs. Their
constructors declare typed variables and allocate struct storage.
All these strings (both in C++ and in wire format) use the character encoding
appropriate to the ISO locale of the sender. For example, the United States is locale
en_US, and uses the Latin-1 character encoding (also called ISO 8859-1); Japan is
locale ja_JP, and uses the Shift-JIS character encoding.
When two programs exchange messages within the same locale, strings are
always correct. However, when a message sender and receiver use different
character encodings, the receiving program must convert between encodings as
needed. Rendezvous software does not convert automatically.
Custom Datatypes
The Rendezvous C++ API does not include classes to support custom datatypes.
However, the C API machinery is available in C++ programs. The Rendezvous
distribution includes a C++ source code example.
Developers of Rendezvous programs can use this checklist during the four phases
of the development cycle: installing Rendezvous software, coding your C++
program, compiling your C++ program, and running your program.
Topics
• Checklist, page 6
• Programming Restrictions, page 7
• Include These Header Files, page 8
• Link These Library Files, page 9
• Source Code Distribution, page 17
Checklist
Code
• Include the appropriate Rendezvous C++ header files; see Include These
Header Files on page 8.
Compile
• Compile your programs.
• VMS requires programmers to define the compile command; see VMS on
page 14.
Link
• Link with the appropriate Rendezvous C++ and C library files; see Link These
Library Files on page 9.
• If name-mangling incompatibilities prevent your program from linking with
the Rendezvous C++ library, you might need to recompile the C++ library. For
more information, see Source Code Distribution on page 17.
• To create a shared library that uses the Rendezvous C++ API, you must
recompile the Rendezvous C++ library. (This step is not necessary on
Windows, AIX and TruUNIX64 platforms.) For more information, see Source
Code Distribution on page 17.
• VMS requires programmers to define the link command; see VMS on page 14.
Run
• Be sure that the Rendezvous daemon can run on each application host
computer. The user’s path must contain a version appropriate for the
application host. For more information, see Rendezvous Daemon (rvd) on
page 41 in TIBCO Rendezvous Administration.
• Be sure that the Rendezvous daemon process can access the Rendezvous
license ticket file, tibrv.tkt. The user’s path must contain this file. For more
information, see Licensing Information on page 11 in TIBCO Rendezvous
Administration.
Programming Restrictions
Rendezvous C++ programs must include the appropriate header files from this
list.
tibrv/tibrvcpp.h Include this header file for the Rendezvous C++ API. This header
automatically includes tibrv.h.
tibrv/cmcpp.h Include this header file for the Rendezvous certified message delivery
and distributed queue C++ API. This header automatically includes
cm.h.
Fault Tolerance
tibrv/ftcpp.h Include this header file for the Rendezvous fault tolerance C++ API.
This header automatically includes ft.h.
tibrv/sdcpp.h Include this header file for the Rendezvous secure daemon C++ API.
This header automatically includes sd.h.
Rendezvous C++ programs must link the appropriate library files. Choose from
the appropriate table based on operating system platform.
32-Bit UNIX
In 32-bit UNIX environments, both shared and static libraries are available. We
recommend shared libraries to ease forward migration.
Secure Daemon
-ltibrvsd Programs that connect to secure daemons (rvsd, rvsrd) must also link using
-lssl
these three flags.
-lcrypto
-ltibrvcm Programs that use certified message delivery must link using this library flag.
Programs that use distributed queues must link using this library flag.
-ltibrvft Programs that use fault tolerance features must link using this library flag.
Programs that use distributed queues must link using this library flag.
64-Bit UNIX
In 64-bit UNIX environments, both shared and static libraries are available. We
recommend shared libraries to ease forward migration. In this release, 64-bit
libraries are available on HP-UX, Solaris and AIX platforms.
-ltibrv64 Programs that connect to ordinary daemons (rvd, rvrd) must link using this
library flag.
Secure Daemon
-ltibrvsd64 Programs that connect to secure daemons (rvd, rvrd) must link using this library
flag.
-ltibrvcm64 Programs that use certified message delivery must link using this library flag.
Programs that use distributed queues must link using this library flag.
-ltibrvft64 Programs that use fault tolerance features must link using this library flag.
Programs that use distributed queues must link using this library flag.
Microsoft Windows
Release 8.3.0 supports Visual C++ in the following combinations:
• Visual C++ (VC8 and VC9) on 32-bit and 64-bit Windows (XP, Server 2003,
Server 2008, Vista)
The C++ library is only available as a static library; the C library is available as a
DLL and as a static library. To create a C++ DLL, you must recompile the
Rendezvous C++ library; see Source Code Distribution on page 17.
Secure Daemon
Programs that connect to secure daemons (rvsd, rvsrd) must link only one of
these sets of libraries.
tibrvsd.lib Secure daemon additions.
libeay32.lib
ssleay32.lib DLL (import library).
Fault Tolerance
Programs that use fault tolerance must link only one of these C libraries.
Programs that use distributed queues must link only one of these libraries.
Distributed Queue
Programs that use distributed queues must link only one of these C libraries.
In addition, distributed queue programs also use certified message delivery,
and fault tolerance libraries; they must link appropriate libraries from those
groups.
VMS
In VMS environments, both shared and static libraries are available. We
recommend shared libraries to ease forward migration.
Forward Migration
In general, applications linked with shareable images migrate forward to new
versions of TIBCO Rendezvous without any need to relink; they usually operate
smoothly with newer shareable images.
Exception: In Rendezvous release 8.0, we reorganized the Rendezvous shareable
image libraries on OpenVMS platforms, in order to resolve issues with third-party
libraries. As a result, you must relink applications linked with shareable image
libraries when you upgrade across this division (from 7.5.4 or earlier, to 8.0 or
later, on OpenVMS).
Compile
On VMS platforms, Rendezvous programmers using C++ (CXX) must define the
CXX-compile command appropriately.
For the HP C++ compiler:
$ CPP :== CXX/FLOAT=IEEE/IEEE_MODE=UNDERFLOW_TO_ZERO -
/PREFIX=ALL/WARNINGS=DISABLE=EXTRASEMI -
/INCLUDE_DIRECTORY=("/tibrv/include",[])
Link
Rendezvous API libraries are multi-threaded, so VMS scheduler upcalls can yield
significant performance improvements:
Library Files
In VMS environments, both shared and static libraries are available. We
recommend shared libraries to ease forward migration.
Secure Daemon
Programs that connect to secure daemons (rvsd, rvsrd) must link only one of
these sets of libraries.
Fault Tolerance
Programs that use fault tolerance must link only one of these libraries.
Programs that use distributed queues must link only one of these libraries.
Distributed Queue
Programs that use distributed queues must link only one of these libraries.
In addition, distributed queue programs also use certified message delivery,
and fault tolerance libraries; they must link appropriate libraries from those
groups.
We compile the C++ API libraries on each platform using the vendor’s primary
compiler. This default case works well in most environments.
For maximum flexibility we also distribute the C++ API as source code. Some
environments are incompatible with the default compilation settings. In these
situations, you can recompile the Rendezvous C++ API libraries to match your
environment. For example:
• The compiler in your environment differs from our primary compiler in its
name-mangling technique. By recompiling the Rendezvous C++ libraries, you
can ensure compatibility with other software compiled in your environment.
• Our static compilation is not position independent (on most platforms). To use
Rendezvous software to produce shared libraries or executables, you must
recompile with appropriate flags.
This brief chapter describes the methods that open and close the internal
machinery upon which Rendezvous software depends.
Topics
• Tibrv, page 20
• TibrvSdContext, page 26
Tibrv
Class
Remarks Programs do not create instances of Tibrv. Instead, programs use its static
methods to open and close the Rendezvous environment, and extract utility
objects.
Utility Objects
Tibrv::close()
Method
After closing a Tibrv object, all events, transports, queues and queue groups
associated with that environment are invalid; it is illegal to call any methods of
these objects.
Reference Count A reference count protects against interactions between programs and third-party
packages that call Tibrv::open() and Tibrv::close(). Each call to
Tibrv::open() increments an internal counter; each call to Tibrv::close()
decrements that counter. A call to Tibrv::open() actually creates internal
machinery only when the reference counter is zero; subsequent calls merely
increment the counter, but do not duplicate the machinery. A call to
Tibrv::close() actually destroys the internal machinery only when the call
decrements the counter to zero; other calls merely decrement the counter. In each
program, the number of calls to Tibrv::open() and Tibrv::close() must
match.
Tibrv::defaultQueue()
Method
Remarks If Rendezvous is not open, the default queue is invalid; nevertheless, this method
returns a pointer to it.
Each process has exactly one default queue; the call Tibrv::open()
automatically creates it. Programs must not destroy the default queue.
Tibrv::open()
Method
Remarks This call creates the internal machinery that Rendezvous software requires for its
operation:
• Internal data structures.
• Default event queue.
• Intra-process transport.
• Event driver.
Until the first call to Tibrv::open() creates the internal machinery, all events,
transports, queues and queue groups are unusable. Messages and their methods
do not depend on the internal machinery.
Reference Count A reference count protects against interactions between programs and third-party
packages that call Tibrv::open() and Tibrv::close(). Each call to
Tibrv::open() increments an internal counter; each call to Tibrv::close()
decrements that counter. A call to Tibrv::open() actually creates internal
machinery only when the reference counter is zero; subsequent calls merely
increment the counter, but do not duplicate the machinery. A call to
Tibrv::close() actually destroys the internal machinery only when the call
decrements the counter to zero; other calls merely decrement the counter. In each
program, the number of calls to Tibrv::open() and Tibrv::close() must
match.
Tibrv::processTransport()
Method
Remarks If Rendezvous is not open, the intra-process transport is invalid; nevertheless, this
method returns a pointer to it.
Each process has exactly one intra-process transport; the call Tibrv::open()
automatically creates it. Programs must not destroy the intra-process transport.
Tibrv::version()
Method
TibrvSdContext
Class
Purpose This class defines static methods for interacting with secure Rendezvous
daemons.
Remarks Programs do not create instances of TibrvSdContext. Instead, programs use its
static methods to configure user names, passwords and certificates, and to
register trust in daemon certificates.
TibrvSdContext:setDaemonCert()
Method
Remarks When any program transport connects to a secure daemon, it verifies the
daemon’s identity using SSL protocols. Certificates registered using this method
identify trustworthy daemons. Programs divulge user names and passwords to
daemons that present registered certificates.
Parameter Description
daemonName Register a certificate for a secure daemon with this name. For
the syntax and semantics of this parameter, see Daemon
Name, below.
daemonCert Register this public certificate. The text of this certificate must
be in PEM encoding.
See also Certificate on page 28.
This string must be identical to the string you supply as the daemon argument to
the transport creation call; see TibrvNetTransport::create() on page 243.
Colon characters (:) separate the three parts.
ssl indicates the protocol to use when attempting to connect to the daemon.
host indicates the host computer of the secure daemon. You can specify this host
either as a network IP address, or a hostname. Omitting this part specifies the
local host.
port_number specifies the port number where the secure daemon listens for SSL
connections.
(This syntax is similar to the syntax connecting to remote daemons, with the
addition of the prefix ssl.)
In place of this three-part string, you can also supply the constant
TIBRV_SECURE_DAEMON_ANY_NAME. This form lets you register a catch-all
certificate that applies to any secure daemon for which you have not explicitly
registered another certificate. For example, you might use this form when several
secure daemons share the same certificate.
Certificate For important details, see CA-Signed Certificates on page 175 in TIBCO
Rendezvous Administration.
In place of an actual certificate, you can also supply the constant
TIBRV_SECURE_DAEMON_ANY_CERT. The program accepts any certificate from the
named secure daemon. For example, you might use this form when testing a
secure daemon configuration, before generating any actual certificates.
TibrvSdContext:setUserCertWithKey()
Method
Purpose Register a (PEM) certificate with private key for identification to secure daemons.
Remarks When any program transport connects to a secure daemon, the daemon verifies
the program’s identity using SSL protocols.
The Rendezvous API includes two methods that achieve similar effects:
• This call accepts a certificate in PEM text format.
• TibrvSdContext:setUserCertWithKeyBin() accepts a certificate in
PKCS #12 binary format.
Parameter Description
userCertWithKey Register this user certificate with private key. The text of
this certificate must be in PEM encoding.
CA-Signed You can also supply a certificate signed by a certificate authority (CA). To use a
Certificate CA-signed certificate, you must supply not only the certificate and private key,
but also the CA’s public certificate (or a chain of such certificates). Concatenate
these items in one string. For important details, see CA-Signed Certificates on
page 175 in TIBCO Rendezvous Administration.
Errors Error status code TIBRV_INVALID_FILE can indicate either disk I/O failure, or
invalid certificate data, or an incorrect password.
TibrvSdContext:setUserCertWithKeyBin()
Method
Purpose Register a (PKCS #12) certificate with private key for identification to secure
daemons.
Remarks When any program transport connects to a secure daemon, the daemon verifies
the program’s identity using SSL protocols.
The Rendezvous API includes two methods that achieve similar effects:
• This call accepts a certificate in PKCS #12 binary format.
• TibrvSdContext:setUserCertWithKey() accepts a certificate in PEM text
format.
Parameter Description
userCertWithKey Register this user certificate with private key. The binary data of this
certificate must be in PKCS #12 format.
CA-Signed You can also supply a certificate signed by a certificate authority (CA). To use a
Certificate CA-signed certificate, you must supply not only the certificate and private key,
but also the CA’s public certificate (or a chain of such certificates). For important
details, see CA-Signed Certificates on page 175 in TIBCO Rendezvous
Administration.
Errors Error status code TIBRV_INVALID_FILE can indicate either disk I/O failure, or
invalid certificate data, or an incorrect password.
TibrvSdContext:setUserNameWithPassword()
Method
Purpose Register a user name with password for identification to secure daemons.
Remarks When any program transport connects to a secure daemon, them daemon verifies
the program’s identity using SSL protocols.
Parameter Description
userName Register this user name for communicating with secure
daemons.
Chapter 4 Data
Topics
To extract data values from the fields of a message, programs use a set of get
convenience methods. All of these methods extract a snapshot of the message
data—that is, the data value as it exists at a particular time. If the program later
modifies the message by removing or updating the field, the snapshot remains
unchanged.
Rendezvous messages implement snapshot semantics using two separate
strategies for scalar data and pointer data.
Scalar Snapshot
To extract the value of a scalar field, a program declares a scalar in
program-owned storage, and passes its address to the get method; the get method
copies a snapshot of the scalar field value from the message into program storage.
The program can modify its snapshot at any time without affecting the original
message. The program can update or delete the message field at any time without
affecting the snapshot copy.
Message
1
Snapshot Copy of
Scalar Field Get Field
Scalar Value
Update Field
Pointer Snapshot
Pointer data is a broad category, which includes arrays, strings, opaque byte
sequences, XML data, and submessages.
To extract the value of an array, string, XML, or opaque field, a program declares a
typed pointer variable in program-owned storage, and passes its reference to the
get method; the get method copies a pointer to the field value into the program’s
variable. The method does not copy data into program-owned storage; the data
still resides in storage associated with the message. Nonetheless, Rendezvous
software protects the integrity of snapshot pointer data from subsequent changes
to the message field.
Pointer to
Array
Array
Value
Snapshot Array
Pointer to
Snapshot
Array Value
of Array 1
Snapshot Array 1
Pointer to
Snapshot of Submsg 1
Snapshot Submsg 1
This pointer remains valid until the
Updated Field in message is destroyed.
Snapshot of Submsg 1
Subsequent calls to get the field from the
Pristine Copy of snapshot submessage extract this new value.
Submsg 1
Unchanged Field in
Copy of Submsg 1
• TibrvMsg::clearReferences()
When a program repeatedly extracts snapshot references data and does not
destroy the parent messages, consider using these methods to control the
proliferation of references.
Message methods specify fields using a combination of a field name and a unique
field identifier. When absent, the default field identifier is zero.
To compare the speed and space characteristics of these two options, see Search
Characteristics on page 40.
3. Begin here when the program supplied zero as the identifier (or omitted a field
identifier).
Search for a field with the specified name—even if that name is NULL. On
failure, return the status code TIBRV_NOT_FOUND.
If a message contains several fields with the same name, searching by name finds
the first instance of the field with that name.
Search Characteristics
In general, an identifier search completes in constant time. In contrast, a name
search completes in linear time proportional to the number of fields in the
message. Name search is quite fast for messages with 16 fields or fewer; for
messages with more than 16 fields, identifier search is faster.
Space Characteristics
The smallest field name is a one-character string, which occupies three bytes in
Rendezvous wire format. That one ASCII character yields a name space of 127
possible field names; a larger range requires additional characters.
Field identifiers are 16 bits, which also occupy three bytes in Rendezvous wire
format. However, those 16 bits yield a space of 65535 possible field identifiers;
that range is fixed, and cannot be extended.
TibrvMsg
Class
Remarks This class lacks create() and destroy() methods; use the constructor and
destructor instead.
(Sheet 1 of 3)
(Sheet 2 of 3)
Fields
Address Information
Field References
(Sheet 3 of 3)
Time String
TibrvMsg()
Constructor
Remarks The first form of this constructor merely declares a C++ variable. It does not
allocate storage; it does not create a C message object. (Subsequent operations on
the variable automatically allocates storage and create the inner structure.) This
form works efficiently with methods such as TibrvTransport::sendRequest(),
which requires a variable to receive its reply message and overwrites the contents
of that variable.
The other forms of this constructor simultaneously declare a variable, allocate
storage, create an object with inner structure, and store the status code in the
object. The status code indicates any conditions that might make the message
object unusable; if the object is unusable, any subsequent operation on the
message will return the same status code.
None of the constructors place address information (for example, the subject) on
the new message object.
This class has no destroy() method; use the destructor instead (see ~TibrvMsg()
on page 46).
(Sheet 1 of 2)
Parameter Description
initialSize Optional.
This form of the constructor declares an empty message
variable. When a subsequent operation triggers storage
allocation, allocate a storage block of this size (in bytes).
(Sheet 2 of 2)
Parameter Description
bytes Create a message with fields populated from this byte array.
The new message is completely independent of the byte array.
For example, programs can create such byte arrays from
messages using the method TibrvMsg::getAsBytes(), and
store them in files; after reading them from such files,
programs can reconstruct a message from its byte array.
~TibrvMsg()
Destructor
Declaration ~TibrvMsg();
TibrvMsg::addField()
Method
Remarks This method copies the data into the new message field. All related convenience
methods behave similarly.
Parameter Description
field Add this field to the message.
Adding Fields to Earlier releases of Rendezvous software allowed programs to append fields to a
a Nested nested submessage under certain conditions. Starting with release 6, Rendezvous
Message software no longer supports this special case convenience. Instead, programs
must use this three-step process:
1. Extract the nested submessage (see Get Nested Message on page 74).
2. Add the new fields to the extracted submessage, using type-specific
convenience methods or this method. The field is added to a snapshot copy of
the submessage, and modifies the copy rather than the original parent
message.
3. Store the modified submessage back into the field of the parent message (see
Update Nested Message on page 104).
Avoiding Whenever possible, we recommend storing arrays in message fields using one of
Common the Rendezvous array types. This strategy makes the most efficient use of storage
Mistakes space, processor time, and network bandwidth.
If you must store array elements as individual fields, be careful mapping array
indices to field identifiers. Zero-based arrays are common in C++ programs, but
zero has a special meaning as a field identifier—it represents the absence of an
identifier. Do not map the zeroth element of an array (myArray[0]) to a field with
identifier zero; it is impossible to retrieve such a field by its identifier (because it
does not have one).
It is illegal to add a field that has both a NULL field name, and a non-zero field
identifier.
Reserved Field
Name
The field name _data_ is reserved. Programs may not add fields with this name.
More generally, all fields that begin with the underbar character are reserved.
Field Name The constant TIBRVMSG_FIELDNAME_MAX (127) determines the longest possible
Length field name.
Convenience When the datatype of a field is determined during execution, use this general
Methods method. When you can determine the datatype of a field before compile-time, we
recommend using type-specific convenience methods instead of this general
method. Type-specific methods yield these advantages when adding fields:
• Code readability.
• Type checking.
• Accept constants and literals directly.
Add Scalar
Convenience Methods
(Sheet 1 of 2)
Parameter Description
fieldName Create the field with this name.
NULL is a legal name. However, if fieldId is non-zero, then
fieldName must be non-NULL.
(Sheet 2 of 2)
Parameter Description
value Add a new field with this value (which may be a literal or
stored in a variable).
The convenience method must correspond to the datatype of
this value. We recommend casting the data to match the
convenience method.
The method copies the value into the new message field.
fieldId Create the new field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field identifiers
must be unique within each message.
It is illegal to add a field that has both a NULL field name, and a
non-zero field identifier.
Add Array
Convenience Methods
(Sheet 1 of 2)
Parameter Description
fieldName Create the new field with this name.
NULL is a legal name. However, if fieldId is non-zero, then
fieldName must be non-NULL.
(Sheet 2 of 2)
Parameter Description
value Add a new field that contains this array.
The method signature must correspond to the datatype of this
value.
The method copies the array into the new message field.
numElements When adding an array type, the program supplies the count of
array elements in this parameter.
fieldId Create the new field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field identifiers
must be unique within each message.
It is illegal to add a field that has both a NULL field name, and a
non-zero field identifier.
Remarks This method adds only the data portion of the nested message (value); it does not
include any address information or certified delivery information.
Parameter Description
fieldName Create the new field with this name.
fieldId Create the new field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field identifiers
must be unique within each message.
It is illegal to add a field that has both a NULL field name, and a
non-zero field identifier.
Add String
Convenience Method
Remarks The string cannot contain interior NULL bytes, because this method expects a
NULL-terminated string. To add a string with interior NULL bytes, use the generic
method TibrvMsg::addField().
Parameter Description
fieldName Create the new field with this name.
value Add a new field that contains this string (which may be a
literal or stored in a variable).
The method copies the data into the new field.
fieldId Create the new field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field identifiers
must be unique within each message.
It is illegal to add a field that has both a NULL field name, and a
non-zero field identifier.
Parameter Description
fieldName Create the new field with this name.
size When adding an opaque buffer, the program supplies the size
(in bytes) of the data in this parameter.
fieldId Create the new field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field identifiers
must be unique within each message.
It is illegal to add a field that has both a NULL field name, and a
non-zero field identifier.
Remarks XML data is a byte sequence. Adding a field of type TIBRVMSG_XML compresses
the bytes. Extracting data from the field uncompresses it to obtain the original
byte sequence.
Parameter Description
fieldName Create the new field with this name.
value Add a new field that contains the XML data in this buffer.
The method copies the data into the new message field.
size When adding XML data, the program supplies the size (in
bytes) of the data in this parameter.
fieldId Create the new field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field identifiers
must be unique within each message.
It is illegal to add a field that has both a NULL field name, and a
non-zero field identifier.
Add DateTime
Convenience Method
Parameter Description
fieldName Create the new field with this name.
fieldId Create the new field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field identifiers
must be unique within each message.
It is illegal to add a field that has both a NULL field name, and a
non-zero field identifier.
Example This example code converts a time_t value to a datetime value, and adds the
datetime to a message field. Programs can adapt this example as appropriate. (For
corresponding code to extract a datetime value from a message field, and convert
it to a time_t value, see the example at Get DateTime, page 78.)
#include <limits.h>
TibrvStatus addAsTimeT(
TibrvMsg& msg,
const char* field,
time_t value)
{
examples/c/ d;
d.sec = (tibrv_i64)value;
return msg.addDateTime(field,d);
}
TibrvMsg::clearReferences()
Method
Remarks This method clears references back to the most recent mark.
For a description and example, see TibrvMsg::markReferences() on page 89.
TibrvMsg::convertToString()
Method
Remarks Programs can use this method to obtain a string representation of the message for
printing.
For most datatypes, this method formats the full value of the field to the string;
these types are an exceptions:
TIBRVMSG_OPAQUE This method abbreviates the value of an opaque field; for
example, [472 opaque bytes].
TIBRVMSG_XML This method abbreviates the value of an XML field; for
example, [XML document: 472 bytes].
The size measures uncompressed data.
Parameter Description
string The program supplies a variable in this parameter; the method
stores the string representation in that variable.
TibrvMsg::createCopy()
Method
Remarks Despite its name, this method does not create a new object. Instead, it stores an
independent copy in the variable it receives as a parameter.
Parameter Description
copy The program supplies a variable in this parameter; the method
stores an independent copy of the message in that variable.
TibrvMsg::detach()
Method
Purpose Detach an inbound message from Rendezvous storage; the program assumes
responsibility for destroying the message.
Remarks When Rendezvous software creates a message, it owns that message. This
situation occurs only in the case of inbound messages presented to a data callback
method; Rendezvous software destroys such messages when the callback method
returns, unless the program explicitly detaches the message. After a detach
operation, the program owns the message, and must explicitly destroy it to
reclaim the storage.
Programs may detach inbound messages. A program cannot detach a message
that it already owns; attempts to do so return NULL.
Programs can use this method to detach either an entire message, or a
submessage. After detaching a submessage, the program owns that submessage,
even after the destruction of the surrounding parent message.
Callback methods receive inbound messages in stack parameters, which
evaporate when the callback methods return. Programs detach messages to allow
the messages to persist beyond the local context. Consequently, the detach
operation returns a new C++ object, which the program can store in a variable
with wider scope. The original inbound message becomes invalid, transferring its
embedded C message to the new C++ message object.
Programs may modify messages only with methods that add, remove or update
fields. It is illegal to directly modify data storage in a message field. Detaching a
message does not change this restriction. For further information, see Do Not
Modify Pointer Snapshots on page 36, or more generally, Validity of Data
Extracted From Message Fields on page 34.
TibrvMsg::expand()
Method
Remarks When adding data to a message would overflow the allocated space, the message
automatically expands by allocating additional storage. However, reallocation
(whether explicit or automatic) is a slow operation; to optimize program
performance, we recommend allocating sufficient storage initially, so that
reallocation is not required.
In most cases, the message expands in place (without copying). In some cases, this
method copies the message to a new location. In all cases, existing pointers to the
message, its fields, and its field values remain valid (even after copying).
If no space is available, this method returns the error code TIBRV_NO_MEMORY.
Parameter Description
additionalStorage Enlarge the message by this amount (in bytes) to
allocate for the message. If the message was oldSize
bytes before this call, it is oldSize + additionalStorage when
the method returns.
TibrvMsg::getAsBytes()
Method
Remarks Return a copy of the message data as a byte sequence, suitable for archiving in a
file. To reconstruct the message from bytes, see TibrvMsg() on page 44.
The byte data includes the message header and all message fields in Rendezvous
wire format. It does not include address information, such as the subject and reply
subject, nor certified delivery information.
The byte sequence can contain interior NULL bytes.
Parameter Description
bytePtr The program supplies a variable. The method stores a pointer to
the byte sequence in that variable.
TibrvMsg::getAsBytesCopy()
Method
Remarks Return the data as a byte sequence, suitable for archiving in a file.
This method copies the message data into a buffer, which the program owns and
may modify.
The byte data includes the message header and all message fields in Rendezvous
wire format. It does not include address information, such as the subject and reply
subject.
To allocate appropriate storage, programs determine the length of the byte
sequence using TibrvMsg::getByteSize() on page 65.
The byte sequence can contain interior NULL bytes.
Parameter Description
bytePtr The program supplies a byte buffer. The method copies the
byte sequence into that buffer.
TibrvMsg::getByteSize()
Method
Remarks This measurement accounts for the actual space that the message occupies (in
wire format), including its header and its fields. It does not include storage that is
allocated but unused. It does not include address information, such as the subject
or reply subject.
Programs can use this method as part of these tasks:
• Measure the size of message before allocating space to store a copy—as with
TibrvMsg::getAsBytesCopy().
Parameter Description
byteSize The program supplies a variable. The method stores the
message size (in bytes) in that variable.
TibrvMsg::getCurrentTime()
Method
Remarks This static method uses an operating system call to get the current time.
Programs can call this method without reference to any message object.
Parameter Description
dateTime The program supplies a variable; the method stores the current
time in that variable.
TibrvMsg::getField()
Method
Remarks Programs specify the field to retrieve using the fieldName and fieldId
parameters. For details, see Field Names and Field Identifiers, page 39.
The method takes a snapshot of the field, and stores that information in the field
argument, overwriting the field object supplied as an argument.
The method copies scalar data into the program’s field object. Pointer data (such
as strings, arrays, submessages, XML data, or opaque byte sequences) extracted
from the field remain valid until the message is destroyed; that is, even removing
the field or updating the field’s value does not invalidate pointer data.
Programs can use a related method to loop through all the fields of a message. To
retrieve each field by its integer index number, see
TibrvMsg::getFieldByIndex() on page 80.
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value that
signifies no field identifier. All non-zero field identifiers must
be unique within each message.
If the name search fails, or if the program supplied NULL as the field name,
return the status code TIBRV_NOT_FOUND.
3. When the program supplied zero as the identifier, search for a field with the
specified name—even if that name is NULL.
If the search succeeds, return the field.
On failure, return the status code TIBRV_NOT_FOUND.
If a message contains several fields with the same name, searching by name finds
the first instance of the field with that name.
Extracting Earlier releases of Rendezvous software allowed programs to get fields from a
Fields from a nested submessage by concatenating field names. Starting with release 6,
Nested Message Rendezvous software no longer supports this special case convenience. Instead,
programs must separately extract the nested submessage using
TibrvMsg::getMsg(), and then get the desired fields from the submessage.
Convenience Methods
In most situations, we recommend using type-specific convenience methods
instead of this general method. Type-specific methods yield these advantages
when extracting fields:
• Code readability.
• Type checking.
• Automatic type conversion.
These categories of type-specific convenience methods find a field and get its
data:
• Get Scalar, page 70.
• Get Array, page 72.
• Get Nested Message, page 74.
• Get String, page 75.
• Get Opaque Byte Sequence, page 76.
• Get XML Byte Sequence, page 77.
• Get DateTime, page 78.
Get Scalar
Convenience Methods
Remarks Each convenience method in this family retrieves a field and extracts its data. If
the field’s type (as it exists) does not match the type of the convenience method,
then the method attempts to convert the data (see Datatype Conversion on
page 376). If conversion is not possible, the method returns
TIBRV_CONVERSION_FAILED.
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value that
signifies no field identifier. All non-zero field identifiers must
be unique within each message.
Get Array
Convenience Methods
Remarks Each convenience method in this family retrieves a field and extracts its data. If
the field’s type (as it exists) is does not match the type of the convenience method,
then the method attempts to convert the data (see Datatype Conversion on
page 376). If conversion is not possible, the method returns
TIBRV_CONVERSION_FAILED.
Pointer data extracted from the field remain valid until the message is destroyed;
that is, even removing the field or updating the field’s value does not invalidate
pointer data.
These methods produce values that are read-only snapshots of the field data (see
Pointer Snapshot on page 35). Programs must not modify elements of the value
array.
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value
that signifies no field identifier. All non-zero field
identifiers must be unique within each message.
Remarks Since it is not possible to convert any other datatype to a message, the field must
already contain a message. Otherwise, the method returns
TIBRV_CONVERSION_FAILED.
Pointer data extracted from the field remain valid until the message is destroyed;
that is, even removing the field or updating the field’s value does not invalidate
pointer data.
After extracting a submessage, a program can detach it. A detached submessage
remains valid and unchanged even after the parent message is destroyed. The
program must explicitly destroy the detached submessage.
This method produces values that are modifiable snapshots of the field data.
Programs may modify the resulting submessage by adding, removing or
updating fields. However, these modifications do not change the field in the
original parent message; instead, they force Rendezvous software to make a copy
of the field (see Rendezvous Protects the Message from Changes to Submessage
Snapshots on page 37).
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value that
signifies no field identifier. All non-zero field identifiers must
be unique within each message.
Get String
Convenience Method
Remarks This convenience method retrieves a field and extracts its data, automatically
converting it to a string.
Programs can use this method to obtain a printable representation of field data.
For most datatypes, this method formats the full value of the field to the output
string; these types are exceptions:
TIBRVMSG_OPAQUE This method abbreviates the value of an opaque field; for
example, [472 opaque bytes].
TIBRVMSG_XML This method abbreviates the value of an XML field; for
example, [XML document: 472 bytes].
The size measures uncompressed data.
Pointer data extracted from the field remain valid until the message is destroyed;
that is, even removing the field or updating the field’s value does not invalidate
pointer data.
This method produces values that are read-only snapshots of the field data (see
Pointer Snapshot on page 35). Programs must not modify the value string.
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value that
signifies no field identifier. All non-zero field identifiers must
be unique within each message.
Remarks This convenience method retrieves a field and extracts its data.
Since it is not possible to convert any other datatype to an opaque byte sequence,
the field must already contain an opaque byte sequence. Otherwise, the method
returns TIBRV_CONVERSION_FAILED.
Pointer data extracted from the field remain valid until the message is destroyed;
that is, even removing the field or updating the field’s value does not invalidate
pointer data.
This method produces values that are read-only snapshots of the field data (see
Pointer Snapshot on page 35). Programs must not modify the value sequence.
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value that
signifies no field identifier. All non-zero field identifiers must
be unique within each message.
Remarks This convenience method retrieves a field and extracts its data.
XML data is a byte sequence. Adding a field of type TIBRVMSG_XML compresses
the bytes. Extracting data from the field uncompresses it to obtain the original
byte sequence.
Since it is not possible to convert any other datatype to an XML byte sequence, the
field must already contain an XML byte sequence. Otherwise, the method returns
TIBRV_CONVERSION_FAILED.
Pointer data extracted from the field remain valid until the message is destroyed;
that is, even removing the field or updating the field’s value does not invalidate
pointer data.
This method produces values that are read-only snapshots of the field data (see
Pointer Snapshot on page 35). Programs must not modify the value sequence.
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value that
signifies no field identifier. All non-zero field identifiers must
be unique within each message.
Get DateTime
Convenience Method
Remarks This convenience method retrieves a field and extracts its data.
Since it is not possible to convert any other datatype to a datetime value, the field
must already contain a datetime. Otherwise, the method returns
TIBRV_CONVERSION_FAILED.
Pointer data extracted from the field remain valid until the message is destroyed;
that is, even removing the field or updating the field’s value does not invalidate
pointer data.
This method produces values that are read-only snapshots of the field data (see
Pointer Snapshot on page 35). Programs must not modify the datetime value.
Parameter Description
fieldName Get a field with this name.
fieldId Get the field with this identifier. Zero is a special value that
signifies no field identifier. All non-zero field identifiers must
be unique within each message.
Example This example code extracts a datetime value from a message field, and converts it
to a time_t value. Programs can adapt this code as appropriate. (For
corresponding code to convert a time_t value to a datetime value, and add the
datetime to a message field, see the example at Add DateTime, page 57.)
#include <limits.h>
TibrvStatus getAsTimeT(
TibrvMsg& msg,
const char* field,
time_t& value)
{
TibrvMsgDateTime d;
TibrvStatus error;
error = msg.getDateTime(field,d);
value = (time_t)d.sec;
}
TibrvMsg::getFieldByIndex()
Method
Remarks Programs can loop through all the fields of a message, to retrieve each field in
turn using an integer index.
The method copies scalar data into the program’s field object. Pointer data
extracted from the field remain valid until the message is destroyed; that is, even
removing the field or updating the field’s value does not invalidate pointer data.
Add, remove and update calls can perturb the order of fields (which, in turn, affects
the results when a program gets a field by index).
Parameter Description
field The program supplies a TibrvMsgField object; the method
overwrites the contents of the object, using information from
the message field.
fieldIndex Get the field with this index. Zero specifies the first field.
TibrvMsg::getFieldInstance()
Method
Remarks When a message contains several field instances with the same field name,
retrieve a specific instance by number (for example, get the ith field named foo).
Programs can use this method in a loop that examines every field with a specified
name.
The argument 1 denotes the first instance of the named field.
The method copies scalar data into the program’s field object. Pointer data
extracted from the field remain valid until the message is destroyed; that is, even
removing the field or updating the field’s value does not invalidate pointer data.
When the instance argument is greater than the actual number of instances of
the field in the message, this method returns the status code TIBRV_NOT_FOUND.
Release 5 Rendezvous 5 (and earlier) did not support array datatypes. Some older
Interaction programs circumvented this limitation by using several fields with the same
name to simulate arrays. This work-around is no longer necessary, since release 6
(and later) supports array datatypes within message fields. The method
TibrvMsg::getFieldInstance() ensures backward compatibility, so new
programs can still receive and manipulate messages sent from older programs.
Nonetheless, we encourage programmers to use array types as appropriate, and
we discourage storing several fields with the same name in a message.
Parameter Description
fieldName Get an instance of the field with this name.
NULL specifies the empty string as the field name.
instance Get this instance of the specified field name. The argument 1
denotes the first instance of the named field.
TibrvMsg::getEvent()
Method
TibrvMsg::getHandle()
Method
TibrvMsg::getNumFields()
Method
Remarks This method counts the immediate fields of the message; it does not descend into
submessages to count their fields recursively.
Parameter Description
numFields The program supplies a variable in this parameter; the method
stores the number of fields in that variable.
TibrvMsg::getReplySubject()
Method
Remarks The reply subject string is part of a message’s address information—it is not part
of the message itself.
If the destination subject is not set, this method passes NULL in the return
parameter.
Parameter Description
replySubject The program supplies a variable in this parameter; the
method stores the reply subject in that variable.
The method makes a snapshot copy of the reply subject
string, and supplies a pointer to that snapshot within
message storage. The pointer remains valid as long as the
message itself remains valid in the same location. The
reply subject pointer becomes invalid if the program
destroys the message, or returns from the data callback
method that determines the scope of an inbound message.
For more information, see Pointer Snapshot on page 35,
and Deleting Snapshot References on page 38.
TibrvMsg::getSendSubject()
Method
Remarks The subject string is part of a message’s address information—it is not part of the
message itself.
If the destination subject is not set, this method passes NULL in the return
parameter.
Parameter Description
sendSubject The program supplies a variable in this parameter; the
method stores the send subject in that variable.
The method makes a snapshot copy of the subject string,
and supplies a pointer to that snapshot within message
storage. The pointer remains valid as long as the message
itself remains valid in the same location. The subject
pointer becomes invalid if the program destroys the
message, or returns from the data callback method that
determines the scope of an inbound message. For more
information, see Pointer Snapshot on page 35, and
Deleting Snapshot References on page 38.
TibrvMsg::getStatus()
Method
Remarks We recommend that programs test the status after calls to TibrvMsg() that copy a
TibrvMsg, or construct a message from a byte array.
TibrvMsg::isDetached()
Method
TibrvMsg::markReferences()
Method
Remarks Extracting pointer data from a message field creates a snapshot of that data. The
snapshot remains associated with the message until the program destroys the
message. However, in rare situations snapshots can accumulate within a program,
causing unbounded memory growth. This method gives programs explicit
control over snapshot references; by clearing references, the program declares that
it no longer needs the references that arise as side effects of calls that get a message
field.
For example, consider a program fragment that repeatedly sends a message,
modifying fields within a nested submessage before each send call. Each call to
extract the nested message produces a snapshot reference. By surrounding the get
operation with a mark and clear pair (with the clear call occurring at any time after
the get call), the program releases the reference, which helps control memory
usage.
void TimerCallback::onTimer(TibrvTimer* timer)
{
TibrvMsg* msg = (TibrvMsg*)timer->getClosure();
msg->markReferences();
TibrvMsg submsg;
msg->getMsg("foo",submsg);
...
msg->clearReferences();
msg->setSendSubject(some_subject);
/* send a message */
transport.send(*msg);
}
Mark 1
Pointer to
Array
Snapshot
Value
1
Snapshot 1
Mark 2
Pointer to
Array
Snapshot
Value
2
Snapshot 2
Unless a program explicitly marks and clears references, references persist until
the message is destroyed or reset.
TibrvMsg::removeField()
Method
Remarks Pointer data (such as strings, arrays, submessages, XML data, or opaque byte
sequences) previously extracted from the field remains valid even after removing
the field from the message.
Parameter Description
fieldName Remove the field with this name.
fieldId Remove the field with this identifier. Zero is a special value
that signifies no field identifier.
Field Search This method uses this algorithm to find and remove a field within a message, as
Algorithm specified by a field identifier and a field name.
1. If the identifier is zero, skip to step 3.
If the program supplied a non-zero field identifier, then search for the field
with that identifier. If the search succeeds, remove the field.
On failure, continue to step 2.
2. If the identifier search (in step 1) fails, and the program supplied a non-NULL
field name, then search for a field with that name.
If the program supplied NULL as the field name, return the status code
TIBRV_NOT_FOUND.
If a message contains several fields with the same name, searching by name
removes the first instance of the field with that name.
TibrvMsg::removeFieldInstance()
Method
Remarks When a message contains several field instances with the same field name,
remove a specific instance by number (for example, remove the ith field named
foo). Programs can use this method in a loop that examines every field with a
specified name.
The argument 1 denotes the first instance of the named field.
If the specified instance does not exist, the method returns TIBRV_NOT_FOUND.
Pointer data (such as strings, arrays, submessages, XML data, or opaque byte
sequences) previously extracted from the field remains valid even after removing
the field from the message.
Parameter Description
fieldName Remove the field with this name.
instance Remove this instance of the field. The argument 1 specifies the
first instance of the named field.
TibrvMsg::reset()
Method
Remarks When this method returns, the message has no fields; it is like a newly created
message. The message’s address information is also reset.
Pointer data (such as strings, arrays, submessages, XML data, or opaque byte
sequences) previously extracted from fields of the old message are invalid.
TibrvMsg::setReplySubject()
Method
Remarks A receiver can reply to an inbound message using its reply subject.
Rendezvous routing daemons modify subjects and reply subjects to enable
transparent point-to-point communication across network boundaries. This
modification does not apply to subject names stored in message data fields; we
discourage storing point-to-point subject names in data fields.
Parameter Description
replySubject Use this string as the new reply subject, replacing any
existing reply subject.
The method copies this string to the message.
The reply subject NULL removes the previous reply subject.
The empty string is not a legal subject name.
TibrvMsg::setSendSubject()
Method
Remarks The subject of a message can describe its content, as well as its destination set.
Rendezvous routing daemons modify subjects and reply subjects to enable
transparent point-to-point communication across network boundaries. This
modification does not apply to subject names stored in message data fields; we
discourage storing point-to-point subject names in data fields.
Parameter Description
sendSubject Use this string as the new subject, replacing any existing
subject.
The method copies this string to the message.
The subject NULL removes the previous subject, leaving the
message unsendable.
The empty string is not a legal subject name.
TibrvMsg::updateField()
Method
Remarks This method locates a field within the message by matching the name and
identifier of field. Then it updates the message field using the field argument.
(Notice that the program may not supply a field object with a different field name,
field identifier, or datatype.)
If no existing field matches the specifications in the field argument, then this
method adds the field to the message. Update convenience methods also add the
field if it is not present.
The type of the existing field (within the message) and the type of the updating
field argument must be identical; otherwise, the method returns the error status
code TIBRV_INVALID_TYPE. However, when updating array or vector fields, the
count (number of elements) can change.
Pointer data (such as strings, arrays, submessages, XML data, or opaque byte
sequences) previously extracted from the field remain valid and unchanged until
the message is destroyed; that is, even updating the field’s value does not
invalidate pointer data.
Parameter Description
field Update the existing message field using this field.
Field Search This method, and related methods that update message fields, all use this
Algorithm algorithm to find and update a field within a message, as specified by a field
identifier and a field name.
1. If the identifier is zero, skip to step 3.
If the program supplied a non-zero field identifier, then search for the field
with that identifier.
If the search succeeds, then update that field.
If the name search succeeds, but the actual identifier in the field is non-NULL
(so it does not match the identifier supplied) then return the status code
TIBRV_ID_CONFLICT.
If the search fails, add the field as specified (with name and identifier).
3. When the program supplied zero as the identifier, search for a field with the
specified name—even if that name is NULL.
If the search fails, add the field as specified (with name and identifier).
If a message contains several fields with the same name, searching by name finds
the first instance of the field with that name.
Reserved Field
Name
The field name _data_ is reserved. Programs may not add fields with this name.
More generally, all fields that begin with the underbar character are reserved.
Field Name The constant TIBRVMSG_FIELDNAME_MAX determines the longest possible field
Length name.
Convenience When the datatype of a field is determined during execution, use this general
Methods method. When you can determine the datatype of a field before compile-time, we
recommend using type-specific convenience methods instead of this general
method. Type-specific methods yield these advantages when updating fields:
• Code readability.
• Type checking.
• Automatic type conversion.
These categories of type-specific convenience methods find a field and update its
data:
• Update Scalar, page 100.
• Update Array, page 102.
• Update Nested Message, page 104.
Nested Message When the new value is a message object, this method uses only the data portion of
the nested message (data); it does not include any address information or
certified delivery information.
Update Scalar
Convenience Methods
Remarks Each convenience method in this family locates a field (by name or identifier) and
updates its data.
The type of the existing field (within the message) and the type of the updating
value must match.
Parameter Description
fieldName Update a field with this name.
value Update the message field to this value (which may be a literal
or stored in a variable).
The method copies the value into the new message field.
fieldId Update the field with this identifier. Zero is a special value that
signifies no field identifier. It is illegal to add a field that has
both a NULL field name, and a non-zero field identifier.
Update Array
Convenience Methods
Remarks Each convenience method in this family locates a field (by name or identifier) and
updates its data.
The type of the existing field (within the message) and the type of the updating
value must match. The number of elements can change.
Pointer data previously extracted from the field remain valid and unchanged
until the message is destroyed; that is, even updating the field’s value does not
invalidate pointer data. (See Pointer Snapshot on page 35.)
Parameter Description
fieldName Update a field with this name.
fieldId Update the field with this identifier. Zero is a special value
that signifies no field identifier. It is illegal to add a field that
has both a NULL field name, and a non-zero field identifier.
Remarks This convenience method locates a field (by name or identifier) and updates its
data.
The type of the existing field (within the message) and the type of the updating
value must match. The message size (that is, its length in bytes) can change.
Pointer data previously extracted from the field remain valid and unchanged
until the message is destroyed; that is, even updating the field’s value does not
invalidate pointer data. (See Rendezvous Protects the Message from Changes to
Submessage Snapshots on page 37.)
This method uses only the data portion of the nested message (value); it does not
include any address information or certified delivery information.
Parameter Description
fieldName Update a field with this name.
fieldId Update the field with this identifier. Zero is a special value that
signifies no field identifier. It is illegal to add a field that has
both a NULL field name, and a non-zero field identifier.
Update String
Convenience Method
Remarks This convenience method locates a field (by name or identifier) and updates its
data.
The type of the existing field (within the message) and the type of the updating
value must match. The length of the string can change.
Pointer data previously extracted from the field remain valid and unchanged
until the message is destroyed; that is, even updating the field’s value does not
invalidate pointer data. (See Pointer Snapshot on page 35.)
Parameter Description
fieldName Update a field with this name.
value Update the message field to this value (which may be a literal
or stored in a variable).
The method copies the new value into the existing field.
fieldId Update the field with this identifier. Zero is a special value that
signifies no field identifier. It is illegal to add a field that has
both a NULL field name, and a non-zero field identifier.
Remarks This convenience method locates a field (by name or identifier) and updates its
data.
The type of the existing field (within the message) and the type of the updating
value must match. The size can change.
Pointer data previously extracted from the field remain valid and unchanged
until the message is destroyed; that is, even updating the field’s value does not
invalidate pointer data. (See Pointer Snapshot on page 35.)
Parameter Description
fieldName Update a field with this name.
size The program supplies the size of the new data in this
parameter.
fieldId Update the field with this identifier. Zero is a special value that
signifies no field identifier. It is illegal to add a field that has
both a NULL field name, and a non-zero field identifier.
Remarks This convenience method locates a field (by name or identifier) and updates its
data.
The type of the existing field (within the message) and the type of the updating
value must match. The size can change.
Pointer data previously extracted from the field remain valid and unchanged
until the message is destroyed; that is, even updating the field’s value does not
invalidate pointer data. (See Pointer Snapshot on page 35.)
XML data is a byte sequence. Adding (or updating) a field of type TIBRVMSG_XML
compresses the bytes. Extracting data from the field uncompresses it to obtain the
original byte sequence.
Parameter Description
fieldName Update a field with this name.
size The program supplies the size of the new data in this
parameter.
fieldId Update the field with this identifier. Zero is a special value that
signifies no field identifier. It is illegal to add a field that has
both a NULL field name, and a non-zero field identifier.
Update DateTime
Convenience Method
Remarks This convenience method locates a field (by name or identifier) and updates its
data.
The type of the existing field (within the message) and the type of the updating
value must match.
Parameter Description
fieldName Update a field with this name.
fieldId Update the field with this identifier. Zero is a special value that
signifies no field identifier. It is illegal to add a field that has
both a NULL field name, and a non-zero field identifier.
TibrvMsgField
Class
Remarks Because the field object is identical to the C field struct, programs can use the
struct’s accessors to get and set the field’s name, data, and other members.
Although a formal destructor is not needed, C++ declares a default destructor,
which has no effect.
(Sheet 1 of 2)
(Sheet 2 of 2)
(For scalar types, strings, XML data, and opaque byte sequences,
count is 1. That is, the field contains one string—not an array of
characters; one opaque value—not an array of bytes.)
id tibrv_u16 The field’s identifier. Identifiers are optional, but must be unique
within each message.
type tibrv_u8 A Rendezvous datatype token denoting the type of the field’s
data.
TibrvMsgField()
Constructor
Declaration TibrvMsgField()
Remarks Because the field object is identical to the C field struct, programs can use the
struct’s accessors to get and set the field’s name, data, and other members.
Parameter Description
field Create an independent copy of this TibrvMsgField object.
TibrvMsgField::getCount()
Method
TibrvMsgField::getData()
Method
Do not use this method to access opaque data that requires memory alignment;
the C struct tibrvLocalData does not necessarily preserve alignment. Instead,
see Add Opaque Byte Sequence on page 55, Get Opaque Byte Sequence on
page 76, or Update Opaque Byte Sequence on page 106.
TibrvMsgField::getId()
Method
Remarks Identifiers are optional, but must be unique within each message.
This method returns the value of the member field.id.
TibrvMsgField::getName()
Method
TibrvMsgField::getSize()
Method
TibrvMsgField::getType()
Method
Remarks Return the Rendezvous datatype token denoting the type of the field’s data.
This method returns the value of the member field.type.
TibrvMsgDateTime
Class
Remarks Because the datetime object is identical to the C field struct, programs can use the
struct’s accessors to get and set the field’s sec and nsec members.
(Sheet 1 of 2)
Operator Description
== Test equality. Operands can be any combination of C++
TibrvMsgDateTime objects and C tibrvMsgDateTime objects.
(Sheet 2 of 2)
Operator Description
!= Test inequality. Operands can be any combination of C++
TibrvMsgDateTime objects and C tibrvMsgDateTime objects.
Representations Rendezvous software represents time values in two ways—one within C and C++
programs, and a more compact wire format within messages. Table 8 on page 119
compares these two representations. In both representations, zero denotes the
epoch, 12:00 midnight, January 1st, 1970. Range limits denote the extreme value
on either side of that center. Bold type indicates the primary unit of measurement
for each representation.
Representation Details
Within C and Seconds as a 64-bit signed integer, plus nanoseconds as a 32-bit unsigned
C++ programs integer.
However, values are restricted to the range and granularity supported by
Rendezvous wire format. Forcing larger or finer values into this representation
produces an error.
Two constants bracket the available (restricted) range of values within
programs— TIBRVMSG_DATETIME_SEC_MAX and TIBRVMSG_DATETIME_SEC_MIN.
TibrvMsgDateTime()
Constructor
Declaration TibrvMsgDateTime()
Remarks With no arguments, this method creates an object representing the epoch (0
seconds, 0 nanoseconds).
Because the datetime object is identical to the C field struct, programs can use the
struct’s accessors to get and set the field’s sec and nsec members.
Parameter Description
dateTime Create an independent copy of this TibrvMsgDateTime object.
This chapter presents classes and methods associated with event interest and
event processing.
Topics
Event Overview
TibrvEvent
Class
Purpose Event objects represent program interest in events, and event occurrences.
Remarks Programs create instances of event subclasses of TibrvEvent, but not of this
superclass.
Each call to a Rendezvous event create method results in a new event object,
which represents your program’s interest in a set of events. Rendezvous software
uses the same event object to signal each occurrence of such an event.
Destroying an event object cancels the program’s interest in that event.
Destroying the queue or transport of an event automatically destroys the event as
well.
Although the fault tolerance classes are technically events, they are sufficiently
different from listeners and timers that they require separate description. See
Chapter 8, Fault Tolerance, on page 259.
TibrvEvent::getHandle() Return the C event handle of this C++ event object. 129
TibrvEvent::destroy()
Method
Remarks Destroying an event object cancels interest in it. Upon return from
TibrvEvent::destroy(), the destroyed event is no longer dispatched. However,
all active callback methods of this event continue to run and return normally, even
though the event is invalid.
It is legal for an event callback method to destroy its own event argument.
Destroying event interest invalidates the event object; subsequent API calls
involving the invalid event return error status, unless explicitly documented to
the contrary.
This method also destroys the C event handle embedded in the C++ event object.
Although TibrvEvent::destroy() prevents future dispatch calls from running
the destroyed event’s callback method, that callback method might be already
running in one or more threads that dispatch events from the same queue. In each
thread where the callback method is already in progress, that callback method
does continue to run until complete. Rendezvous software ensures that the
completion method runs when the last callback-in-progress has completed; for
important details, see TibrvEventOnComplete::onComplete() on page 140.
Parameter Description
completeCB Rendezvous software runs the completion callback method
immediately after all instances of the event’s callback method
have completed. If the event’s callback method is not running
when the event is destroyed, the destroy call runs it before
returning.
If this parameter is NULL, TibrvEvent::destroy() does not
trigger a completion method.
TibrvEvent::getClosure()
Method
Remarks If no closure data is set for the event object, this method returns NULL.
This method can extract the closure data even from invalid events.
TibrvEvent::getHandle()
Method
Remarks If the event is invalid, this method returns the constant TIBRV_INVALID_ID.
TibrvEvent::getType()
Method
Parameter Description
type The program supplies a variable. This method stores the event
type in that variable.
TibrvEvent::getQueue()
Method
TibrvEvent::isIOEvent()
Method
Remarks This method returns TIBRV_TRUE when the event is an I/O event. Otherwise, it
returns TIBRV_FALSE.
TibrvEvent::isListener()
Method
Remarks This method returns TIBRV_TRUE when the event is a listener (including a
certified delivery listener). Otherwise, it returns TIBRV_FALSE.
TibrvEvent::isTimer()
Method
Remarks This method returns TIBRV_TRUE when the event is a timer. Otherwise, it returns
TIBRV_FALSE.
TibrvEvent::isValid()
Method
Remarks This method returns TIBRV_FALSE if it has been destroyed (using the destroy
method); TIBRV_TRUE otherwise.
Notice that TibrvEvent::destroy() invalidates the event immediately, even
though active callback methods may continue to run.
TibrvEvent::isVectorListener()
Method
Remarks This method returns TIBRV_TRUE when the event is a vector listener. Otherwise, it
returns TIBRV_FALSE.
TibrvCallback
Class
Remarks Programs can implement this interface to process events. Subclass interfaces
process specific types of events.
TibrvCallback::onEvent()
Method
Parameter Description
event This parameter receives the event.
TibrvEventOnComplete
Class
Purpose Run program code after all callback methods of a destroyed event have
completed.
TibrvEventOnComplete::onComplete()
Method
Purpose A program can destroy an event object even when its callback method is running
in one or more threads. Multi-threaded programs can define methods of this type
to discover when all callback methods in progress have completed.
Parameter Description
destroyedEvent This parameter receives the event object. This object is
identical to the object that the program created to express
event interest.
However, by the time this method runs, the event is
already destroyed; this method cannot use the event object
in Rendezvous calls.
software runs the completion method immediately, in the same thread as the
callback method that completes last.
• Figure 7 on page 142 illustrates a situation in which the program calls
TibrvEvent::destroy() when the destroyed event’s callback method is not
running in any thread. In this case, TibrvEvent::destroy() calls the
completion method before returning.
Notice that in this situation, the completion method runs in the program
context, instead of the usual context of a callback method. In rare instances,
deadlock can occur, resulting from unintended interactions between mutex
operations in the program context before the destroy call, and mutex
operations in the program’s completion method code.
To protect against this type of deadlock, programmers can use a
straightforward thought-experiment as a preventive test. Expand the
completion method code immediately after the call to
TibrvEvent::destroy()—as it would run when the destroyed event’s
callback method is not running in any thread. Trace mutex locking activity
within this context to determine whether the resulting code could violate
established rules for proper use of mutex locks.
...
mutex lock operations
...
myEvent::destoy()
expand completion method code here, and check for violations of mutex rules
...
Event Valid
TibrvListener
Class
Remarks A listener object continues listening for messages until the program destroys it.
The constructor creates a hollow object; the create method makes it operational.
The destructor calls the destroy method, unless the C object is already destroyed.
Destroying the queue or transport of a listener event automatically invalidates the
listener as well.
Inherited Methods
TibrvEvent::destroy()
TibrvEvent::getClosure()
TibrvEvent::getHandle()
TibrvEvent::getType()
TibrvEvent::getQueue()
TibrvEvent::isValid()
TibrvEvent::isListener()
TibrvEvent::isTimer()
TibrvEvent::isIOEvent()
Figure 8 illustrates that Rendezvous software does not deactivate the listener
when it places new message events on the queue (in contrast to I/O events, which
are temporarily deactivated). Consequently, several messages can accumulate in
the queue while the callback method is processing.
3. Dispatch event.
Callback
Event Waiting in
Function
Queue
Running
Callback
Event Waiting in Queue Function
Running
Callback
Event Waiting in Queue Function
Running
6. Destroying listener
Event Waiting in
More messages arrive. cancels messages in
Queue
the queue.
When the callback method is I/O-bound, messages can arrive faster than the
callback method can process them, and the queue can grow unacceptably long. In
programs where a delay in processing messages is unacceptable, consider
dispatching from several threads to process messages concurrently.
TibrvListener::create()
Method
Remarks This method creates a C listener and stores its handle in the C++ object.
Parameter Description
queue For each inbound message, place the event on this event
queue.
subject Listen for inbound messages with subjects that match this
specification. Wildcard subjects are permitted. The empty
string is not a legal subject name.
Listening for Use this method to listen for advisory subjects. We recommend sending advisory
Advisory message events to the default queue.
Messages
Inbox Listener To receive unicast (point-to-point) messages, listen to an inbox subject name. First
call TibrvTransport::createInbox() to create the unique inbox name; then call
TibrvListener::create() to begin listening. Remember that other programs
have no information about an inbox until the listening program uses it as a reply
subject in an outbound message. See also, Inbox Names on page 115 in TIBCO
Rendezvous Concepts.
TibrvListener::getSubject()
Method
Parameter Description
subject The program supplies a variable. The method stores the
subject of the listener event object in that variable.
Remarks Programs must not free nor modify the resulting subject string.
TibrvListener::getTransport()
Method
TibrvMsgCallback
Class
TibrvMsgCallback::onMsg()
Method
Parameter Description
listener This parameter receives the listener event.
CM Label The callback method for certified delivery messages can use certified delivery
Information (CM) label information to discriminate among these situations:
• If TibrvCmMsg::getSender() returns status code TIBRV_NOT_FOUND, then the
message uses the reliable protocol (that is, it was sent from an ordinary
transport).
• If TibrvCmMsg::getSender() returns a valid sender name, then the message
uses the certified delivery protocol (that is, it is a labeled message, sent from a
CM transport).
TibrvVectorListener
Class
Remarks A vector listener object continues listening for messages until the program
destroys it.
The constructor creates a hollow object; the create method makes it operational.
The destructor calls the destroy method, unless the C object is already destroyed.
Destroying the queue or transport of a vector listener event automatically
invalidates the vector listener as well.
Inherited Methods
TibrvEvent::destroy()
TibrvEvent::getClosure()
TibrvEvent::getHandle()
TibrvEvent::getType()
TibrvEvent::getQueue()
TibrvEvent::isValid()
TibrvEvent::isListener()
TibrvEvent::isTimer()
TibrvEvent::isIOEvent()
TibrvVectorListener::create()
Method
Remarks This method creates a C vector listener and stores its handle in the C++ object.
Parameter Description
queue Place each inbound message on this event queue.
subject Listen for inbound messages with subjects that match this
specification. Wildcard subjects are permitted. The empty
string is not a legal subject name.
Interoperability Vector listeners and ordinary listeners can listen on the same queue.
Grouping When several vector listeners use the same queue, the dispatcher groups
Messages into messages into vectors with the following properties:
Vectors
• The sequence of messages in a vector reflect consecutive arrival in the queue.
• All messages in a vector share the same callback object (though they need not
match the same listener).
Because messages 49 and 50 require different callbacks, the dispatcher must close
the vector of FOO and PHU messages at message 49, and start a new vector for
message 50 with subject BAR. When the dispatcher encounters message 51 with
subject FOO again, it closes the BAR vector after only one message, and starts a
third vector for FOO.
Message Queue
Dispatch Order Messages dispatch in the order that they arrive in the queue. However, the order
vs. in which callbacks process messages can differ from dispatch order. The following
Processing examples illustrate this possibility by contrasting three scenarios.
Order
Example 4 Vector Listeners: Deliberately Processing Out of Order
The simplest callback (from the programmer’s perspective) processes the
messages within a vector in order (that is, the order that dispatcher moves them
from the queue into the vector, which mirrors the order in which the messages
arrive in the queue). Nonetheless you could program a callback that processes
messages in reverse order, or any other order (though one would need a
convincing reason to do so).
Msgs 1 - 49 Msgs 51 - 80
50 51
49
Thread A
Msgs 1 - 49
Thread B 49
50 Thread C
Msgs 51 - 80
51
Although message number 49 dispatches (in event A) before message 50 (in event
B), it is possible for the BAR callback (in thread B) to process message 50 before the
FOO callback (in thread A) processes message 49. Furthermore, it is even possible
for the FOO callback (in thread C) to process message 51 before the FOO callback (in
thread A) processes message 49.
TibrvVectorListener::getSubject()
Method
Parameter Description
subject The program supplies a variable. The method stores the
subject of the vector listener event object in that variable.
Remarks Programs must not free nor modify the resulting subject string.
TibrvVectorListener::getTransport()
Method
TibrvVectorCallback
Class
TibrvVectorCallback::onMsgs()
Method
Parameter Description
messages This parameter receives an array of pointers to inbound messages.
TibrvTimer
Class
Remarks All timers are repeating timers. To simulate a once-only timer, code the callback
method to destroy the timer.
The destructor calls the destroy method, unless the C object is already destroyed.
Destroying the queue of a timer automatically destroys the timer as well.
Activation and The method TibrvTimer::create() creates a C timer event object, and activates
Dispatch the timer event—that is, it requests notification from the operating system when
the timer’s interval elapses. When the interval elapses, Rendezvous software
places the event object on its event queue. Dispatch removes the event object from
the queue, and runs the callback method to process the timer event. When the
callback method begins, Rendezvous software automatically reactivates the
event, using the same interval. On dispatch Rendezvous software also determines
whether the next interval has already elapsed, and requeues the timer event if
appropriate. (To stop the cycle, destroy the event object; see
TibrvEvent::destroy() on page 127.)
Notice that time waiting in the event queue until dispatch can increase the
effective interval of the timer. It is the programmer’s responsibility to ensure
timely dispatch of events.
Figure 12 illustrates a sequence of timer intervals. The number of elapsed timer
intervals directly determines the number of event callbacks.
At any moment the timer object appears on the event queue at most once—not
several times as multiple copies. Nonetheless, Rendezvous software arranges for
the appropriate number of timer event callbacks based the number of intervals
that have elapsed since the timer became active or reset its interval.
Destroying or invalidating the timer object immediately halts the sequence of timer
events. The timer object ceases to queue new events, and an event already in the
queue does not result in a callback. (However, callback methods that are already
running in other threads continue to completion.)
Resetting the timer interval immediately interrupts the sequence of timer events
and begins a new sequence, counting the new interval from that moment. The
reset operation is equivalent to destroying the timer and creating a new object in
its place.
1. Activate timer.
Timer Express the timer interval (in seconds) as a 64-bit floating point number. This
Granularity representation allows microsecond granularity for intervals for over 100 years.
The actual granularity of intervals depends on hardware and operating system
constraints.
Inherited Methods
TibrvEvent::destroy()
TibrvEvent::getClosure()
TibrvEvent::getHandle()
TibrvEvent::getType()
TibrvEvent::getQueue()
TibrvEvent::isValid()
TibrvEvent::isListener()
TibrvEvent::isTimer()
TibrvEvent::isIOEvent()
TibrvTimer::create()
Method
Parameter Description
queue At each time interval, place the event on this event queue.
interval The timer triggers its callback method at this repeating interval
(in seconds).
Remarks This method creates a C timer, activates it, and stores its handle in the C++ object.
Timer Express the timer interval (in seconds) as a 64-bit floating point number. This
Granularity representation allows microsecond granularity for intervals for over 100 years.
The actual granularity of intervals depends on hardware and operating system
constraints.
Zero as Interval Many programmers traditionally implement user events as timers with interval
zero. Instead, we recommend implementing user events as messages on the
intra-process transport. For more information, see Intra-Process Transport and
User Events on page 114 in TIBCO Rendezvous Concepts.
TibrvTimer::getInterval()
Method
Parameter Description
interval The program supplies a variable. The method stores the
interval of the timer event object in that variable.
TibrvTimer::resetInterval()
Method
Parameter Description
newInterval The timer triggers its callback method at this new
repeating interval (in seconds).
Timer Express the timer interval (in seconds) as a 64-bit floating point number. This
Granularity representation allows microsecond granularity for intervals up to approximately
146 years. The actual granularity of intervals depends on hardware and operating
system constraints.
Limit of This method can affect a timer only before or during its interval—but not after its
Effectiveness interval has elapsed.
This method neither examines, changes nor removes an event that is already
waiting in a queue for dispatch. If the next event for the timer object is already in
the queue, then that event remains in the queue, representing the old interval. The
change takes effect with the subsequent interval. (To circumvent this limitation, a
program can destroy the old timer object and replace it with a new one.)
TibrvTimerCallback
Class
TibrvTimerCallback::onTimer()
Method
Parameter Description
timer This parameter receives the timer event.
TibrvIOEvent
Class
Activation and The method TibrvIOEvent::create() creates an event object that describes an
Dispatch I/O situation, and activates the event—that is, it requests notification from the
operating system when that I/O situation occurs. When the situation occurs,
Rendezvous software deactivates the event, and places the event object on its
event queue. Dispatch removes the event object from the queue, and runs the
callback method to process the event. When the callback method returns,
Rendezvous software automatically reactivates the event. (To stop the cycle,
destroy the event object; see TibrvEvent::destroy() on page 127.)
Figure 13 illustrates that Rendezvous software temporarily deactivates the I/O
event from the time it enters the queue until its callback method returns.
Consequently, an I/O object can cause at most one event at a time.
Event Callback
I/O Event
Waiting in Function
Active
Queue Running
Event
I/O Event
Waiting in
Active
Queue
Semantics of I/O The semantics of all I/O conditions depend on the underlying operating system
Events and event manager. Rendezvous software does not change those semantics.
I/O events trigger when the operating system reports that an I/O condition on a
monitored socket would succeed (that is, transfer at least one byte without
blocking). Nonetheless, Rendezvous software cannot guarantee that a subsequent
I/O call will not block.
Inherited Methods
TibrvEvent::destroy()
TibrvEvent::getClosure()
TibrvEvent::getHandle()
TibrvEvent::getType()
TibrvEvent::getQueue()
TibrvEvent::isValid()
TibrvEvent::isListener()
TibrvEvent::isTimer()
TibrvEvent::isIOEvent()
TibrvIOEvent::create()
Method
Parameter Description
queue At each time interval, place the event on this event queue.
Remarks This method creates a C I/O event and stores its handle in the C++ object.
All timers are repeating timers. To simulate a once-only timer, code the callback
method to destroy the timer.
TibrvIOEvent::getIOSource()
Method
Purpose Extract the source (socket ID) from an I/O event object.
Parameter Description
source The program supplies a variable. The method stores the source
of the I/O event object in that variable.
TibrvIOEvent::getIOType()
Method
Parameter Description
ioType The program supplies a variable. The method stores the source
of the I/O event object in that variable.
See tibrvIOType on page 162 in TIBCO Rendezvous C
Reference.
TibrvIOCallback
Class
TibrvIOCallback::onIOEvent()
Method
Parameter Description
ioEvent This parameter receives the I/O event.
TibrvDispatchable
Class
Dispatch
TibrvDispatchable::destroy()
Method
Remarks When a queue is destroyed, events that remain in the queue are discarded.
When a queue group is destroyed, the individual queues in the group continue to
exist, even though the group has been destroyed.
TibrvDispatchable::dispatch()
Method
Remarks If an event is ready to dispatch, then this call dispatches it, and then returns. If no
events are waiting, then this call blocks indefinitely while waiting for the object to
receive an event.
Both TibrvQueue and TibrvQueueGroup implement this method.
TibrvDispatchable::getDispatchable()
Method
Remarks If the event is invalid, this method returns the constant TIBRV_INVALID_ID.
TibrvDispatchable::isValid()
Method
TibrvDispatchable::poll()
Method
Remarks If an event is ready to dispatch, then this call dispatches it, and then returns. If no
events are waiting, then this call returns immediately.
When the call dispatches an event, it returns TIBRV_OK. When the call does not
dispatch an event, it returns the status code TIBRV_TIMEOUT.
This call is equivalent to timedDispatch(0).
Both TibrvQueue and TibrvQueueGroup implement this method.
TibrvDispatchable::timedDispatch()
Method
Purpose Dispatch an event, but if no event is ready to dispatch, limit the time that this call
blocks while waiting for an event.
Remarks If an event is ready to dispatch, then this call dispatches it, and then returns. If no
events are waiting, this call waits for an event to arrive. If an event arrives before
the waiting time elapses, then it dispatches the event and returns. If the waiting
time elapses first, then the call returns without dispatching an event.
When the call dispatches an event, it returns the status code TIBRV_OK. When the
call does not dispatch an event, it returns the status code TIBRV_TIMEOUT.
Both TibrvQueue and TibrvQueueGroup implement this method.
Parameter Description
timeout Maximum time (in seconds) that this call can block while
waiting for an event to arrive.
TIBRV_NO_WAIT (zero) indicates no blocking (immediate
timeout).
TIBRV_WAIT_FOREVER (-1) indicates no timeout.
TibrvQueue
Class
Remarks Each event is associated with a TibrvQueue object; when the event occurs,
Rendezvous software places the event object in its queue. Programs dispatch
queues to process events.
The constructor produces a hollow object; TibrvQueue::create() makes it
operational.
The destructor calls the destroy method, unless the C object is already destroyed.
Limit Policy These constants specify the possible strategies for resolving overflow of queue
limit.
(Sheet 1 of 2)
Constant Description
TIBRVQUEUE_DISCARD_NONE Never discard events; use this policy when a
queue has no limit on then number of events it
can contain.
TIBRVQUEUE_DISCARD_LAST Discard the last event in the queue (that is, the
youngest event in the queue).
(Sheet 2 of 2)
Constant Description
TIBRVQUEUE_DISCARD_NEW Discard the new event (which would
otherwise cause the queue to overflow its
maximum events limit).
Dispatch
Properties
Inherited Methods
TibrvDispatchable::getDispatchable()
TibrvDispatchable::destroy()
TibrvDispatchable::dispatch()
TibrvDispatchable::isValid()
TibrvDispatchable::poll()
TibrvDispatchable::timedDispatch()
TibrvQueue::create()
Method
Remarks This method creates a C queue and stores its handle in the C++ object.
Upon creation, new queues use these default values for properties.
discardAmount zero
TibrvQueue::destroy()
Method
TibrvStatus destroy (
TibrvQueueOnComplete* completeCB,
const void* closure = NULL);
Remarks When a queue is destroyed, events that remain in the queue are discarded.
The destructor calls this method.
When a program destroys a queue, all events associated with the queue become
invalid. These invalid events still occupy storage until the program explicitly
destroys them, or until the program calls Tibrv::close().
A program must not call TibrvQueue::destroy() on the default queue. Closing
Tibrv destroys the default queue; see Tibrv::close() on page 21.
Parameter Description
completeCB Rendezvous software runs this method immediately after all
event callback methods dispatched from the queue have
completed. If no event callback methods are running when the
queue is destroyed, the destroy call runs the completion
method before returning.
If this parameter is NULL, this method does not run a
completion.
TibrvQueue::dispatch()
Method
Remarks If the queue is not empty, then this call dispatches the event at the head of the
queue, and then returns. If the queue is empty, then this call blocks indefinitely
while waiting for the queue to receive an event.
TibrvQueue::getCount()
Method
Parameter Description
numEvents The program supplies a variable, and the method stores (a
snapshot of) the event count of the queue in that variable.
TibrvQueue::getHandle()
Method
TibrvQueue::getLimitPolicy()
Method
Parameter Description
policy Each queue has a policy for discarding events when a new
event would cause the queue to exceed its maxEvents
limit. For an explanation of the policy values, see Limit
Policy on page 184.
The program supplies a variable, and the method stores
the limit policy of the queue in that variable.
maxEvents Programs can limit the number of events that a queue can
hold—either to curb queue growth, or implement a
specialized dispatch semantics.
Zero specifies an unlimited number of events.
The program supplies a variable, and the method stores
the maximum event limit of the queue in that variable.
discardAmount When the queue exceeds its maximum event limit, discard
a block of events. This property specifies the number of
events to discard.
The program supplies a variable, and the method stores
the discard amount of the queue in that variable.
TibrvQueue::getName()
Method
Parameter Description
queueName The program supplies a variable, and the method stores in that
variable a string pointer to the queue name.
The program must not modify the string.
TibrvQueue::getPriority()
Method
Remarks Each queue has a single priority value, which controls its dispatch precedence
within queue groups. Higher values dispatch before lower values; queues with
equal priority values dispatch in round-robin fashion.
When the queue is invalid, this method returns TIBRV_INVALID_QUEUE.
TibrvQueue::isValid()
Method
Remarks Returns TIBRV_TRUE if the queue is valid; TIBRV_FALSE if the queue has been
destroyed.
TibrvQueue::poll()
Method
Remarks If the queue is not empty, then this call dispatches the event at the head of the
queue, and then returns. If the queue is empty, then this call returns immediately.
When the call dispatches an event, it returns the status code TIBRV_OK. When the
call does not dispatch an event, it returns the status code TIBRV_TIMEOUT.
This call is equivalent to timedDispatch(0).
TibrvQueue::setLimitPolicy()
Method
Remarks This method simultaneously sets three related properties, which together describe
the behavior of a queue in overflow situations. Each call must explicitly specify all
three properties.
Parameter Description
limitPolicy Each queue has a policy for discarding events when a new
event would cause the queue to exceed its maxEvents limit.
Choose from the values of tibrvQueueLimitPolicy.
When maxEvents is zero (unlimited), the policy must be
TIBRVQUEUE_DISCARD_NONE.
The program supplies a value, and the method sets the limit
policy of the queue to that value.
maxEvents Programs can limit the number of events that a queue can
hold—either to curb queue growth, or implement a
specialized dispatch semantics.
Zero specifies an unlimited number of events; in this case,
the policy must be TIBRVQUEUE_DISCARD_NONE.
The program supplies a value, and the method sets the
maximum event limit of the queue to that value.
discardAmount When the queue exceeds its maximum event limit, discard a
block of events. This property specifies the number of
events to discard.
When discardAmount is zero, the policy must be
TIBRVQUEUE_DISCARD_NONE.
TibrvQueue::setName()
Method
Parameter Description
queueName Replace the name of the queue with this new name.
It is illegal to supply NULL as the new queue name.
TibrvQueue::setPriority()
Method
Remarks Each queue has a single priority value, which controls its dispatch precedence
within queue groups. Higher values dispatch before lower values; queues with
equal priority values dispatch in round-robin fashion.
Changing the priority of a queue affects its position in all the queue groups that
contain it.
Parameter Description
priority Replace the priority of the queue with this new value.
The priority is a non-negative integer. Priority zero signifies
the last queue to dispatch.
TibrvQueue::timedDispatch()
Method
Purpose Dispatch an event, but if no event is ready to dispatch, limit the time that this call
blocks while waiting for an event.
Remarks If an event is already in the queue, this call dispatches it, and returns immediately.
If the queue is empty, this call waits for an event to arrive. If an event arrives
before the waiting time elapses, then it dispatches the event and returns. If the
waiting time elapses first, then the call returns without dispatching an event.
When the call dispatches an event, it returns the status code TIBRV_OK. When the
call does not dispatch an event, it returns the status code TIBRV_TIMEOUT.
Parameter Description
timeout Maximum time (in seconds) that this call can block while
waiting for an event to arrive in the queue.
TIBRV_NO_WAIT (zero) indicates no blocking (immediate
timeout).
TIBRV_WAIT_FOREVER (-1) indicates no timeout.
TibrvQueueOnComplete
Class
Purpose Run program code after all callback methods of a destroyed queue have
completed.
TibrvQueueOnComplete::onComplete()
Method
Purpose A program can destroy a queue object even when callback methods from its
events are running in one or more threads. Multi-threaded programs can define
methods of this type to discover when all event callback methods in progress
have completed.
Parameter Description
queue This parameter receives the queue object.
However, by the time this method runs, the queue is already
destroyed; this method cannot use the queue object in
Rendezvous calls.
closure This parameter receives the closure object that the program
supplied in the destroy call.
Remarks This method is important when several threads dispatch from the same queue,
and the program must do additional processing after the callback methods have
completed in all threads.
Upon return from TibrvQueue::destroy(), the destroyed queue can no longer
dispatch events. However, in each thread where an event callback method is
already in progress, that callback method does continue to run until complete.
TibrvQueue::destroy() accepts an argument of type TibrvQueueOnComplete.
Rendezvous software ensures that the completion method runs when the last
callback-in-progress has completed.
TibrvQueueGroup
Class
Remarks Queue groups add flexibility and fine-grained control to the event queue dispatch
mechanism. Programs can create groups of queues and dispatch them according
to their queue priorities.
The constructor creates a hollow object; TibrvQueueGroup::create() makes it
operational.
The destructor calls the destroy method, unless the C object is already destroyed.
(Sheet 1 of 2)
Dispatch
Queues
(Sheet 2 of 2)
Inherited Methods
TibrvDispatchable::getDispatchable()
TibrvDispatchable::destroy()
TibrvDispatchable::dispatch()
TibrvDispatchable::isValid()
TibrvDispatchable::poll()
TibrvDispatchable::timedDispatch()
TibrvQueueGroup::add()
Method
Remarks If the queue is already in the group, adding it again has no effect.
Parameter Description
eventQueue Add this event queue to a queue group.
TibrvQueueGroup::create()
Method
Remarks This method creates a C queue group and stores its handle in the C++ object.
The new queue group is empty.
The queue group remains valid until the program explicitly destroys it.
TibrvQueueGroup::destroy()
Method
Remarks The individual queues in the group continue to exist, even though the group has
been destroyed.
TibrvQueueGroup::dispatch()
Method
Remarks If any queue in the group contains an event, then this call searches the queues in
priority order, dispatches an event from the first non-empty queue that it finds,
and then returns. If all the queues are empty, then this call blocks indefinitely
while waiting for any queue in the group to receive an event.
When searching the group for a non-empty queue, this call searches according to
the priority values of the queues. If two or more queues have identical priorities,
subsequent dispatch and poll calls rotate through them in round-robin fashion.
TibrvQueueGroup::getHandle()
Method
TibrvQueueGroup::isValid()
Method
Remarks Returns TIBRV_TRUE if the queue group is valid; TIBRV_FALSE if the queue group
has been destroyed.
TibrvQueueGroup::poll()
Method
Remarks If any queue in the group contains an event, then this call searches the queues in
priority order, dispatches an event from the first non-empty queue that it finds,
and then returns. If all the queues are empty, then this call returns immediately.
When searching the group for a non-empty queue, this call searches according to
the priority values of the queues. If two or more queues have identical priorities,
subsequent dispatch and poll calls rotate through them in round-robin fashion.
When the call dispatches an event, it returns the status code TIBRV_OK. When the
call does not dispatch an event, it returns the status code TIBRV_TIMEOUT.
This call is equivalent to timedDispatch(0).
TibrvQueueGroup::remove()
Method
Remarks If the queue is not in the group, this call returns the status code
TIBRV_INVALID_QUEUE.
Parameter Description
eventQueue Remove this event queue from a queue group.
TibrvQueueGroup::timedDispatch()
Method
Purpose Dispatch an event, but if no event is ready to dispatch, limit the time that this call
blocks while waiting for an event.
Remarks If any queue in the group contains an event, then this call searches the queues in
priority order, dispatches an event from the first non-empty queue that it finds,
and then returns. If the queue is empty, this call waits for an event to arrive in any
queue. If an event arrives before the waiting time elapses, then the call searches
the queues, dispatches the event, and returns. If the waiting time elapses first,
then the call returns without dispatching an event.
When searching the group for a non-empty queue, this call searches according to
the priority values of the queues. If two or more queues have identical priorities,
subsequent dispatch calls rotate through them in round-robin fashion.
When the call dispatches an event, it returns the status code TIBRV_OK. When the
call does not dispatch an event, it returns the status code TIBRV_TIMEOUT.
Parameter Description
timeout Maximum time (in seconds) that this call can block while
waiting for an event to arrive in the queue group.
TIBRV_NO_WAIT (zero) indicates no blocking (immediate
timeout).
TIBRV_WAIT_FOREVER (-1) indicates no timeout.
TibrvDispatcher
Class
TibrvDispatcher::create()
Method
Remarks This method creates a C dispatcher thread and stores its handle in the C++ object.
A dispatcher thread repeatedly dispatches a queue or queue group.
Inside the thread, a loop calls TibrvDispatchable::timedDispatch(). If the
timed dispatch call returns without dispatching an event (after waiting for
idleTimeout seconds), then the thread exits by calling
TibrvDispatcher::destroy().
Parameter Description
dispatchable The new thread dispatches this object, which can be either a
queue or a queue group.
Stack Size On UNIX platforms that use the POSIX thread package (pthread), this call sets
the stacksize attribute of the dispatcher thread to the larger of two candidate
values—either the default stack size of the operating system, or 64 kilobytes.
For programs that require a larger stack size, we recommend that you code a
custom dispatcher thread.
TibrvDispatcher::destroy()
Method
Remarks We do not recommend destroying a dispatcher thread within the same thread (for
example, from within a listener callback function running within that thread).
Although it is legal to do so, we discourage this practice, because some operating
systems do not properly free internal resources associated with the thread (which
can result in memory growth).
TibrvDispatcher::getDispatchable()
Method
Purpose Extract the queue or queue group that this thread dispatches.
TibrvDispatcher::getHandle()
Method
TibrvDispatcher::getName()
Method
Parameter Description
dispatchName The program supplies a variable, and the method stores
the name of the dispatcher thread in that variable.
TibrvDispatcher::isValid()
Method
Remarks This method returns TIBRV_TRUE if the dispatcher object is valid, and
TIBRV_FALSE if it has been destroyed.
TibrvDispatcher::setName()
Method
Parameter Description
dispatchName Use this name as the name of the dispatcher thread.
Chapter 6 Transports
Topics
See Also
TibrvCmTransport on page 307
TibrvCmQueueTransport on page 356
TibrvTransport
Class
This class is the superclass of all other transport classes. Methods defined by this
class are implemented by all transport subclasses (except
TibrvCmQueueTransport, for which some methods do not apply).
Intra-Process Each process has exactly one intra-process transport; the call Tibrv::open()
Transport automatically creates it, and the call Tibrv::processTransport() extracts it.
Programs must not destroy the intra-process transport.
(Sheet 1 of 2)
(Sheet 2 of 2)
TibrvTransport::createInbox()
Method
Remarks This method creates inbox names that are unique throughout the transport scope.
• For network transports, inbox subject names are unique across all processes
within the local router domain—that is, anywhere that direct multicast contact
is possible. The inbox name is not necessarily unique outside of the local
router domain.
• For the intra-process transport, inbox names are unique across all threads of
the process.
This method creates only the unique name for an inbox; it does not begin listening
for messages on that subject name. To begin listening, pass the inbox name as the
subject argument to TibrvListener::create(). The inbox name is only valid
for use with the same transport that created it. When calling
TibrvListener::create(), you must pass the same transport object that created
the inbox subject name.
Remember that other programs have no information about an inbox subject name
until the listening program uses it as a reply subject in an outbound message.
Use inbox subject names for delivery to a specific destination. In the context of a
network transport, an inbox destination specifies unicast (point-to-point)
delivery.
Rendezvous routing daemons (rvrd) translate inbox subject names that appear as
the send subject or reply subject of a message. They do not translate inbox subject
names within the data fields of a message.
This inherited method is disabled for TibrvCmQueueTransport objects.
This method is the only legal way for programs to create inbox subject names.
Parameter Description
subjectString The program supplies a string buffer, and the method
stores the new inbox subject string in that buffer.
TibrvTransport::destroy()
Method
Remarks Programs must explicitly destroy each transport object, either using this method,
or by calling Tibrv::close() (which destroys all transports).
Destroying a transport achieves these effects:
• The transport flushes all outbound data to the Rendezvous daemon.
This effect is especially important, and neither exiting the program nor calling
Tibrv::close() is sufficient to flush outbound data.
• The transport invalidates (but does not destroy) all associated listeners.
• Subsequent calls that use the destroyed transport return an error status.
• Storage for the transport object is freed.
TibrvTransport::getDescription()
Method
TibrvTransport::getHandle()
Method
TibrvTransport::isValid()
Method
Remarks Returns TIBRV_TRUE if the transport is valid; TIBRV_FALSE if the transport has
been destroyed.
TibrvTransport::requestReliability()
Method
Parameter Description
reliability Request this reliability interval (in seconds).
This value must be greater than zero.
Remarks This call lets application programs shorten the reliability interval of the specific
service associated with a transport object. Successful calls change the daemon’s
reliability interval for all transports within the application process that use the
same service.
Programs can request reliability only from daemons of release 8.2 or later.
An application can request a shorter retention time than the value that governs
the daemon as a whole (either the factory default or the daemons -reliability
parameter). The daemon’s governing value silently overrides calls that request a
longer retention time.
Maximum Value Client transport objects that connect to the same daemon could specify different
Rule reliability intervals on the same service—whether by requesting a reliability
value, or by using the daemon’s effective value. In this situation, the daemon
selects the largest potential value from among all the transports on that service,
and uses that maximum value as the effective reliability interval for the service
(that is, for all the transports on the service). This method of resolution favors the
more stringent reliability requirements. (Contrast this rule with the Lower Value
Rule that applies between two daemons.)
Recomputing the Whenever a transport connects, requests reliability, or disconnects from the
Reliability daemon, the daemon recalculates the reliability interval for the corresponding
service, by selecting the largest value of all transports communicating on that
service.
When recomputing the reliability interval would result in a shorter retention time,
the daemon delays using the new value until after an interval equivalent to the
older (longer) retention time. This delay ensures that the daemon retains message
data at least as long as the effective reliability interval at the time the message is
sent.
TibrvTransport::send()
Method
Parameter Description
message Send this message.
TibrvTransport::sendReply()
Method
Remarks This convenience call extracts the reply subject of an inbound request message,
and sends an outbound reply message to that subject. In addition to the
convenience, this call is marginally faster than using separate calls to extract the
subject and send the reply.
This method overwrites any existing send subject of the reply message with the
reply subject of the request message.
Parameter Description
replyMessage Send this outbound reply message.
Give special attention to the order of the arguments to this method. Reversing the
inbound and outbound messages can cause an infinite loop, in which the program
repeatedly resends the inbound message to itself (and all other recipients).
TibrvTransport::sendRequest()
Method
This call blocks all other activity on its program thread. If appropriate,
programmers must ensure that other threads continue dispatching events on its
queues.
Parameter Description
message Send this message.
reply The program supplies a variable, and the method stores the
inbound reply in that variable.
The program owns the reply message, and must call its destructor
to reclaim storage.
timeout Maximum time (in seconds) that this call can block while
waiting for a reply.
TIBRV_WAIT_FOREVER (-1) indicates no timeout (wait without
limit for a reply).
Remarks The status code TIBRV_TIMEOUT indicates that the specified time expired before
receiving a reply.
Programs that receive and process the request message cannot determine that the
sender has blocked until a reply arrives.
The request message must have a valid destination subject; see
TibrvMsg::setSendSubject() on page 96.
TibrvTransport::setDescription()
Method
Parameter Description
description Use this string as the new program description.
tibrvTransportBatchMode
Type
Value Description
TIBRV_TRANSPORT_DEFAULT_B Default batch behavior. The transport transmits outbound
ATCH messages to rvd as soon as possible.
This value is the initial default for all transports.
TibrvProcessTransport
Class
Purpose The intra-process transport delivers messages among the threads of a program.
Inherited Methods
TibrvTransport::createInbox()
TibrvTransport::destroy()
TibrvTransport::isValid()
TibrvTransport::getHandle()
TibrvTransport::send()
TibrvTransport::sendReply()
TibrvTransport::sendRequest()
TibrvTransport::setDescription()
TibrvNetTransport
Class
Inherited Methods
TibrvTransport::createInbox()
TibrvTransport::destroy()
TibrvTransport::isValid()
TibrvTransport::getHandle()
TibrvTransport::send()
TibrvTransport::sendReply()
TibrvTransport::sendRequest()
TibrvTransport::setDescription()
TibrvNetTransport::create()
Method
TibrvStatus createLicensed(
const char* service,
const char* network,
const char* daemon,
const char* license_ticket);
Remarks This method creates a C network transport and stores its handle in the C++ object.
Parameter Description
service The Rendezvous daemon divides the network into logical partitions. Each
TibrvNetTransport communicates on a single service; a transport can
communicate only with other transports on the same service.
To communicate on more than one service, a program must create more than
one transport—one transport for each service.
You can specify the service in several ways. For details, see Service Parameter
on page 103 in TIBCO Rendezvous Concepts.
NULL specifies the default rendezvous service.
network Every network transport communicates with other transports over a single
network interface. On computers with more than one network interface, the
network parameter instructs the Rendezvous daemon to use a particular
network for all outbound messages from this transport.
To communicate over more than one network, programs must create more than
one transport.
You can specify the network in several ways. For details, see Network
Parameter on page 107 in TIBCO Rendezvous Concepts.
NULL specifies the primary network interface for the host computer.
Parameter Description
daemon The daemon parameter instructs the transport object about how and where to
find the Rendezvous daemon and establish communication.
For details, see Daemon Parameter on page 110 in TIBCO Rendezvous Concepts.
You can specify a daemon on a remote computer. For details, see Remote
Daemon on page 111 in TIBCO Rendezvous Concepts.
If you specify a secure daemon, this string must be identical to as the
daemonName argument of TibrvSdContext:setDaemonCert() on page 27. See
also, Secure Daemon on page 111 in TIBCO Rendezvous Concepts.
null specifies the default—find the local daemon on TCP socket 7500. (This
default is not valid when the local daemon is a secure daemon.)
licenseTicket Embed this special license ticket in the transport object. When a licensed
transport connects to rvd, it presents this special ticket to validate its
connection (rvd uses the longest-running ticket available, which can be either
this special ticket, or a ticket from the ticket file, tibrv.tkt).
Ordinary license tickets are not valid for this parameter; see also, Embedded
License on page 245.
Description As a debugging aid, we recommend setting a unique description string for each
String transport. Use a string that distinguishes both the application and the role of the
transport within it. See TibrvTransport::setDescription() on page 238.
TibrvNetTransport::getDaemon()
Method
Parameter Description
daemonString The program supplies a variable, and the method places in
that variable a string pointer to the daemon information.
The program must not modify nor free the string.
TibrvNetTransport::getNetwork()
Method
Purpose Return the network interface that this transport uses for communication.
Parameter Description
networkString The program supplies a variable, and the method places in
that variable a string pointer to the network information.
The program must not modify nor free the string.
TibrvNetTransport::getService()
Method
Purpose Return the effective service that this transport uses for communication.
Parameter Description
serviceString The program supplies a variable, and the method places in
that variable a string pointer to the service information.
The program must not modify nor free the string.
TibrvNetTransport::setBatchMode()
Method
Remarks The batch mode determines when the transport transmits outbound message data
to rvd:
• As soon as possible (the initial default for all transports)
• Either when its buffer is full, or when a timer interval expires—either event
triggers transmission to the daemon
Parameter Description
mode Use this value as the new batch mode.
Topics
TibrvVcTransport
Class
Remarks A virtual circuit transport can fill the same roles as an ordinary transport.
Programs can use them to create inbox names, send messages, create listeners and
other events.
The constructor creates a hollow object; programs call one of the two create
methods to makes operational.
The destructor calls the destroy method, unless the C object is already destroyed.
Two methods determine the protocol role of the transport object—one method
creates a terminal that accepts connections, and another method creates a terminal
that attempts to connect.
The two types of terminal play complementary roles as they attempt to establish a
connection. However, this difference soon evaporates. After the connection is
complete, the two terminals behave identically.
Direct Because virtual circuits rely on point-to-point messages between the two
Communication terminals, they can use direct communication to good advantage. To do so, both
terminals must use network transports that enable direct communication.
For an overview, see Direct Communication on page 116 in TIBCO Rendezvous
Concepts.
For programming details, see Specifying Direct Communication on page 105 in
TIBCO Rendezvous Concepts.
Inherited Methods
Legal Methods TibrvTransport::createInbox()
TibrvTransport::destroy()
TibrvTransport::getHandle()
TibrvTransport::isValid()
TibrvTransport::send()
TibrvTransport::sendReply()
TibrvTransport::sendRequest()
TibrvVcTransport::createAcceptVc()
Method
Remarks This method creates a C accept transport and stores its handle in the C++ object.
Parameter Description
connectSubject The program supplies a location, and the method stores the connect subject of
the new virtual circuit accept transport in that location.
After this call returns, the program must send a message to another program,
inviting it to establish a virtual circuit. Furthermore, the reply subject of that
invitation message must be this connect subject. To complete the virtual circuit,
the second program must extract this subject from the invitation, and supply it
to TibrvVcTransport::createConnectVc().
transport The virtual circuit uses this ordinary transport for communications.
Programs may use this transport for other purposes.
It is illegal to supply a virtual circuit transport object for this parameter (that is,
you cannot nest a virtual circuit within another virtual circuit).
Test Before Either of two conditions indicate that the connection is ready to use:
Using
• The transport presents the VC.CONNECTED advisory.
• TibrvVcTransport::waitForVcConnection() returns without error.
Immediately after this call, test both conditions with these two steps (in this
order):
1. Listen on the virtual circuit transport object for the VC.CONNECTED advisory.
2. Call TibrvVcTransport::waitForVcConnection() with zero as the timeout
parameter.
For an explanation, see Testing the New Connection on page 123 in TIBCO
Rendezvous Concepts.
TibrvVcTransport::createConnectVc()
Method
Remarks This method creates a C connect transport and stores its handle in the C++ object.
Parameter Description
connectSubject The connect transport uses this connect subject to establish a virtual circuit
with an accept transport in another program.
The program must receive this connect subject from the accepting program.
The call to TibrvVcTransport::createAcceptVc() creates this subject.
transport The virtual circuit uses this ordinary transport for communications.
Programs may use this transport for other purposes.
It is illegal to supply a virtual circuit transport object for this parameter (that is,
you cannot nest a virtual circuit within another virtual circuit).
Test Before Either of two conditions indicate that the connection is ready to use:
Using
• The transport presents the VC.CONNECTED advisory.
• TibrvVcTransport::waitForVcConnection() returns without error.
Immediately after this call, test both conditions with these two steps (in this
order):
1. Listen on the virtual circuit transport object for the VC.CONNECTED advisory.
2. Call TibrvVcTransport::waitForVcConnection() with zero as the timeout
parameter.
For an explanation, see Testing the New Connection on page 123 in TIBCO
Rendezvous Concepts.
TibrvVcTransport::waitForVcConnection()
Method
Remarks This method tests (and can block) until this virtual circuit transport object has
established a connection with its opposite terminal. You may call this method for
either an accept terminal or a connect terminal.
This method produces the same information as the virtual circuit advisory
messages—but it produces it synchronously (while advisories are asynchronous).
Programs can use this method not only to test the connection, but also to block
until the connection is ready to use.
For example, a program can create a terminal object, then call this method to wait
until the connection completes.
Parameter Description
timeout This parameter determines the behavior of the call:
• For a quick test of current connection status, supply zero. The call returns
immediately, without blocking.
• To wait for a new terminal to establish a connection, supply a reasonable
positive value. The call returns either when the connection is complete, or
when this time limit elapses.
• To wait indefinitely for a usable connection, supply -1. The call returns
when the connection is complete. If the connection was already complete
and is now broken, the call returns immediately.
(Sheet 1 of 2)
Status Description
TIBRV_OK The connection is complete (ready to use).
TIBRV_TIMEOUT The connection is not yet complete, but the non-negative time limit
for waiting has expired.
(Sheet 2 of 2)
Status Description
TIBRV_VC_NOT_CONNECTED The connection was formerly complete, but is now irreparably
broken.
Topics
tibrvftAction
Type
} tibrvftAction;
Remarks Each token of this enumerated type designates a command to a fault tolerance
callback method. The program’s callback method receives one of these tokens in a
parameter, and interprets it as an instruction from the Rendezvous fault tolerance
software as described in this table (see also, Fault Tolerance Callback Actions on
page 214 in TIBCO Rendezvous Concepts).
Token Description
TIBRVFT_PREPARE_TO_ACTIVATE Prepare to activate (hint).
Rendezvous fault tolerance software passes this token to the
callback method to instruct the program to make itself ready to
activate on short notice—so that if the callback method
subsequently receives the instruction to activate, it can do so
without delay.
This token is a hint, indicating that the program might soon
receive an instruction to activate. It does not guarantee that an
activate instruction will follow, nor that any minimum time
will elapse before an activate instruction follows.
TibrvFtMember
Class
(Sheet 1 of 2)
Properties
(Sheet 2 of 2)
TibrvFtMember::create()
Method
Remarks This method creates a C fault tolerance member object, and stores it in the C++
object. The program becomes a member of the fault tolerance group.
A program may hold simultaneous memberships in several distinct fault
tolerance groups. For examples, see Multiple Groups on page 217 in TIBCO
Rendezvous Concepts.
Avoid joining the same group twice. It is illegal for a program to maintain more
than one membership in any one fault tolerance group. This method does not
guard against this illegal situation, and results are unpredictable.
All arguments are required except for preparationInterval (which may be
zero) and closure (which may be NULL).
Intervals The heartbeat interval must be less than the activation interval. If the preparation
interval is non-zero, it must be greater than the heartbeat interval and less than
the activation interval. It is an error to violate these rules.
In addition, intervals must be reasonable for the hardware and network
conditions. For information and examples, see Step 4: Choose the Intervals on
page 235 in TIBCO Rendezvous Concepts.
Group Name The group name must be a legal Rendezvous subject name (see Subject Names on
page 61 in TIBCO Rendezvous Concepts). You may use names with several
elements; for examples, see Multiple Groups on page 217 in TIBCO Rendezvous
Concepts.
(Sheet 1 of 3)
Parameter Description
queue Place fault tolerance events for this member on this event queue.
(Sheet 2 of 3)
Parameter Description
callback On dispatch, process the event with this callback object.
transport Use this transport for fault tolerance internal protocol messages (such as
heartbeat messages).
weight Weight represents the ability of this member to fulfill its purpose, relative
to other members of the same fault tolerance group. Rendezvous fault
tolerance software uses relative weight values to select which members
to activate; members with higher weight take precedence over members
with lower weight.
Acceptable values range from 1 to 65535. Zero is a special, reserved
value; Rendezvous fault tolerance software assigns zero weight to
processes with resource errors, so they only activate when no other
members are available.
For more information, see Rank and Weight on page 204 in TIBCO
Rendezvous Concepts.
heartbeatInterval When this member is active, it sends heartbeat messages at this interval
(in seconds).
The interval must be positive. To determine the correct value, see Step 4:
Choose the Intervals on page 235 in TIBCO Rendezvous Concepts.
(Sheet 3 of 3)
Parameter Description
preparationInterval When the heartbeat signal from one or more active members has been
silent for this interval (in seconds), Rendezvous fault tolerance software
issues an early warning hint (TIBRVFT_PREPARE_TO_ACTIVATE) to the
ranking inactive member. This warning lets the inactive member prepare
to activate, for example, by connecting to a database server, or allocating
memory.
The interval must be non-negative. Zero is a special value, indicating
that the member does not need advance warning to activate;
Rendezvous fault tolerance software never issues a
TIBRVFT_PREPARE_TO_ACTIVATE hint when this value is zero. To
determine the correct value, see Step 4: Choose the Intervals on page 235
in TIBCO Rendezvous Concepts.
activationInterval When the heartbeat signal from one or more active members has been
silent for this interval (in seconds), Rendezvous fault tolerance software
considers the silent member to be lost, and issues the instruction to
activate (TIBRVFT_ACTIVATE) to the ranking inactive member.
When a new member joins a group, Rendezvous fault tolerance software
identifies the new member to existing members (if any), and then waits
for this interval to receive identification from them in return. If, at the
end of this interval, it determines that too few members are active, it
issues the activate instruction (TIBRVFT_ACTIVATE) to the new member.
Then interval must be positive. To determine the correct value, see Step
4: Choose the Intervals on page 235 in TIBCO Rendezvous Concepts.
TibrvFtMember::destroy()
Method
TibrvFtMember::getClosure()
Method
TibrvFtMember::getGroupName()
Method
Parameter Description
groupName The program supplies a variable, and the method stores the
group name in that variable.
The program must not modify this string nor free its storage.
TibrvFtMember::getHandle()
Method
TibrvFtMember::getQueue()
Method
TibrvFtMember::getTransport()
Method
TibrvFtMember::getWeight()
Method
Parameter Description
weight The program supplies a variable, and the method stores the
weight in that variable.
TibrvFtMember::isValid()
Method
Remarks Returns TIBRV_TRUE if the C member is valid; TIBRV_FALSE if the member has
been destroyed or is otherwise invalid.
TibrvFtMember::setWeight()
Method
Purpose Change the weight of a fault tolerance member within its group.
Remarks Weight summarizes the relative suitability of a member for its task, relative to
other members of the same fault tolerance group. That suitability is a combination
of computer speed and load factors, network bandwidth, computer and network
reliability, and other factors. Programs may reset their weight when any of these
factors change, overriding the previous assigned weight.
You can use relative weights to indicate priority among group members.
Zero is a special value; Rendezvous fault tolerance software assigns zero weight
to processes with resource errors, so they only activate when no other members
are available. Programs must always assign weights greater than zero.
When Rendezvous fault tolerance software requests a resource but receives an
error (for example, the member process cannot allocate memory, or start a timer),
it attempts to send the member process a DISABLING_MEMBER advisory message,
and sets the member’s weight to zero, effectively disabling the member. Weight
zero implies that this member is active only as a last resort—when no other
members outrank it. (However, if the disabled member process does become
active, it might not operate correctly.)
Parameter Description
weight The new weight value. See weight on page 265.
See Also Adjusting Member Weights on page 225 in TIBCO Rendezvous Concepts.
TibrvFtMemberCallback
Class
TibrvFtMemberCallback::onFtAction()
Method
Remarks Each member program of a fault tolerance group must implement this method.
Programs register a member callback object (and this method) with each call to
TibrvFtMember::create().
This token is a hint, indicating that the program might soon receive an
instruction to activate. It does not guarantee that an activate instruction will
follow, nor that any minimum time will elapse before an activate instruction
follows.
For additional information see Fault Tolerance Callback Actions on page 214 in
TIBCO Rendezvous Concepts.
Parameter Description
ftMember This parameter receives the member object.
groupName This parameter receives a string denoting the name of the fault
tolerance group.
TibrvFtMemberOnComplete
Class
Purpose A program can destroy a member object even when its callback method is
running in one or more threads. Multi-threaded programs can define a subclass of
this interface class to discover when all callback methods in progress have
completed.
TibrvFtMemberOnComplete::onComplete
Method
Purpose A program can destroy a member object even when its callback method is
running in one or more threads. Multi-threaded programs can define methods of
this type to discover when all callback methods in progress have completed.
Parameter Description
ftMember This parameter receives the member event object. This object is
identical to the object that the program created to join the fault
tolerance group.
However, by the time this method runs, the member is already
destroyed; this method cannot use the member object in
Rendezvous calls.
TibrvFtMonitor
Class
(Sheet 1 of 2)
Properties
(Sheet 2 of 2)
TibrvFtMonitor::create()
Method
Remarks The monitor callback method receives the number of active members as an
argument.
The group need not have any members at the time of this create call.
Parameter Description
queue Place events for this monitor on this event queue.
lostInterval When the heartbeat signal from an active member has been
silent for this interval (in seconds), Rendezvous fault
tolerance software considers that member lost, and queues a
monitor event.
The interval must be positive. To determine the correct
value, see Step 4: Choose the Intervals on page 235 in TIBCO
Rendezvous Concepts.
See also, Lost Interval on page 284.
Lost Interval The monitor uses the lostInterval to determine whether a member is still
active. When the heartbeat signal from an active member has been silent for this
interval (in seconds), the monitor considers that member lost, and queues a
monitor event.
We recommend setting the lostInterval identical to the group’s
activationInterval, so the monitor accurately reflects the behavior of the
group members.
Group Name The group name must be a legal Rendezvous subject name (see Subject Names on
page 61 in TIBCO Rendezvous Concepts). You may use names with several
elements; for examples, see Multiple Groups on page 217 in TIBCO Rendezvous
Concepts.
TibrvFtMonitor::destroy()
Method
Purpose Stop monitoring a fault tolerance group, and free associated resources.
Remarks This method returns an error when the monitor object is already invalid, or when
its queue or transport are invalid.
TibrvFtMonitor::getClosure()
Method
TibrvFtMonitor::getGroupName()
Method
Parameter Description
groupName The program supplies a variable, and the method stores the
group name in that variable.
TibrvFtMonitor::getHandle()
Method
TibrvFtMonitor::getQueue()
Method
TibrvFtMonitor::getTransport()
Method
TibrvFtMonitor::isValid()
Method
Remarks Returns TIBRV_TRUE if the C monitor is valid; TIBRV_FALSE if the monitor has
been destroyed or is otherwise invalid.
TibrvFtMonitorCallback
Class
TibrvFtMonitorCallback::onFtMonitor()
Remarks A program must define a method of this type as a prerequisite to monitor a fault
tolerance group. Programs register a monitor callback method with each call to
TibrvFtMonitor::create() on page 283.
Parameter Description
ftMonitor This parameter receives the monitor object.
TibrvFtMonitorOnComplete
Class
Purpose A program can destroy a monitor object even when its callback method is running
in one or more threads. Multi-threaded programs can define a subclass of this
interface class to discover when all callback methods in progress have completed.
TibrvFtMonitorOnComplete::onComplete
Method
Purpose A program can destroy a monitor object even when its callback method is running
in one or more threads. Multi-threaded programs can define methods of this type
to discover when all callback methods in progress have completed.
Parameter Description
ftMonitor This parameter receives the monitor event object. This object is
identical to the object that the program created to begin
monitoring the fault tolerance group.
However, by the time this method runs, the monitor is already
destroyed; this method cannot use the monitor object in
Rendezvous calls.
See Also
This API implements Rendezvous certified delivery features. For a complete
discussion, see Certified Message Delivery on page 139 in TIBCO Rendezvous
Concepts.
Certified delivery software uses advisory messages extensively. For example,
advisories inform sending and receiving programs of the delivery status of each
message. For complete details, see Certified Message Delivery (RVCM) Advisory
Messages on page 287 in TIBCO Rendezvous Concepts.
If your application sends or receives certified messages across network
boundaries, you must configure the Rendezvous routing daemons to exchange
_RVCM administrative messages. For details, see Certified Message Delivery on
page 401 in TIBCO Rendezvous Administration.
Some programs require certified delivery to one of n worker processes. See
Distributed Queue on page 181 in TIBCO Rendezvous Concepts.
Topics
TibrvCmListener
Class
Purpose A certified delivery listener object listens for labeled messages and certified
messages.
(Sheet 1 of 2)
(Sheet 2 of 2)
Properties
Inherited Methods
TibrvEvent::destroy()
TibrvEvent::getClosure()
TibrvEvent::getHandle()
TibrvEvent::getType()
TibrvEvent::getQueue()
TibrvEvent::isValid()
TibrvEvent::isListener()
TibrvEvent::isTimer()
TibrvEvent::isIOEvent()
TibrvCmListener::confirmMsg()
Method
Remarks Use this method only in programs that override automatic confirmation (see
TibrvCmListener::setExplicitConfirm() on page 306). The default behavior
of certified listeners is to automatically confirm delivery when the callback
method returns.
Parameter Description
message Confirm receipt of this message.
Unregistered When a CM listener receives a labeled message, its behavior depends on context:
Message
• If a CM listener is registered for certified delivery, it presents the
supplementary information to the callback method. If the sequence number is
present, then the receiving program can confirm delivery.
• If a CM listener is not registered for certified delivery with the sender, it
presents the sender’s name to the callback method, but omits the sequence
number. In this case, the receiving program cannot confirm delivery;
TibrvCmListener::confirmMsg() returns the status code
TIBRV_NOT_PERMITTED.
Notice that the first labeled message that a program receives on a subject
might not be certified; that is, the sender has not registered a certified delivery
agreement with the listener. If appropriate, the certified delivery library
automatically requests that the sender register the listener for certified
delivery. (See Discovery and Registration for Certified Delivery on page 154 in
TIBCO Rendezvous Concepts.)
A labeled but uncertified message can also result when the sender explicitly
disallows or removes the listener.
TibrvCmListener::create()
Method
Purpose Listen for messages that match the subject, and request certified delivery when
available.
Parameter Description
queue For each inbound message, place the listener event on this
event queue.
subject Listen for inbound messages with subjects that match this
specification. Wildcard subjects are permitted. The empty
string is not a legal subject name.
Activation and Details of listener event semantics are identical to those for ordinary listeners; see
Dispatch Activation and Dispatch on page 143.
Inbox Listener To receive unicast (point-to-point) messages, listen to a unique inbox subject
name. First call TibrvTransport::createInbox() to create the unique inbox
name; then call TibrvListener::create() to begin listening. Remember that
other programs have no information about an inbox until the listening program
uses it as a reply subject in an outbound message.
TibrvCmListener::destroy()
Method
Parameter Description
cancelAgreements TIBRV_TRUE cancels all certified delivery agreements
of this listener; certified senders delete from their
ledgers all messages sent to this listener.
TIBRV_FALSE leaves all certified delivery agreements
in effect, so certified senders continue to store
messages.
Canceling When destroying a certified delivery listener, a program can either cancel its
Agreements certified delivery agreements with senders, or let those agreements persist (so a
successor listener can receive the messages covered by those agreements).
When canceling agreements, each (previously) certified sender transport receives
a REGISTRATION.CLOSED advisory. Successor listeners cannot receive old
messages.
TibrvCmListener::getSubject()
Method
Parameter Description
subject The program supplies a variable. The method stores the subject
of the listener event object in that variable.
The program must not modify this string nor free its storage.
TibrvCmListener::getTransport()
Method
TibrvCmListener::isValid()
Method
Remarks This method returns TIBRV_TRUE if the listener is valid, and TIBRV_FALSE if it has
been destroyed.
Notice that TibrvCmListener::destroy() invalidates the event immediately,
even though active callback methods may continue to run.
TibrvCmListener::setExplicitConfirm()
Method
TibrvCmTransport
Class
Purpose A certified delivery transport object implements the CM delivery protocol for
messages.
(Sheet 1 of 3)
(Sheet 2 of 3)
(Sheet 3 of 3)
Inherited Methods
TibrvTransport::createInbox()
TibrvTransport::destroy()
TibrvTransport::isValid()
TibrvTransport::getHandle()
TibrvTransport::send()
TibrvTransport::sendReply()
TibrvTransport::sendRequest()
TibrvTransport::setDescription()
TibrvCmTransport::addListener()
Method
Remarks Some sending programs can anticipate requests for certified delivery—even
before the listening programs actually register. In such situations, the sending
transport can pre-register listeners, so Rendezvous software begins storing
outbound messages in the sender’s ledger; when the listener requests certified
delivery, it receives the backlogged messages.
If the correspondent with this cmName already receives certified delivery of this
subject from this sender transport, then TibrvCmTransport::addListener()
has no effect.
If the correspondent with this cmName is disallowed,
TibrvCmTransport::addListener() returns the status TIBRV_NOT_PERMITTED.
You can call TibrvCmTransport::allowListener() to supersede the effect of a
prior call to TibrvCmTransport::disallowListener(); then call
TibrvCmTransport::addListener() again.
It is not sufficient for a sender to use this method to anticipate listeners; the
anticipated listening programs must also require old messages when creating
certified delivery transports.
Parameter Description
cmName Anticipate a listener from a correspondent with this reusable
name.
subject Anticipate a listener for this subject. Wildcard subjects are illegal.
TibrvCmTransport::allowListener()
Method
Purpose Invite the named receiver to reinstate certified delivery for its listeners,
superseding the effect of any previous disallow calls.
Remarks Upon receiving the invitation to reinstate certified delivery, Rendezvous software
at the listening program automatically sends new registration requests. The
sending program accepts these requests, restoring certified delivery.
Parameter Description
cmName Accept requests for certified delivery to listeners at the transport
with this correspondent name.
TibrvCmTransport::connectToRelayAgent()
Method
Remarks Programs may specify a relay agent when creating a CM transport object.
Connect calls are non-blocking; they immediately return control to the program,
and asynchronously attempt to connect to the relay agent (continuing until they
succeed, or until the program makes a disconnect call).
When a transport attempts to connect to a relay agent, Rendezvous software
automatically locates the relay agent process (if it exists). When the program
successfully connects to the relay agent, they synchronize:
• The transport receives a RELAY.CONNECTED advisory, informing it of
successful contact with the relay agent. (Listen for all advisory messages on
the ordinary TibrvTransport that the TibrvCmTransport employs.)
(When a program cannot locate its relay agent, certified delivery software
produces DELIVERY.NO_RESPONSE advisories; however, we recommend
against designing programs to rely on this side effect.)
• If the client transport is a CM listener, the relay agent listens to the same set of
subjects on behalf of the client. The relay agent also updates its confirmation
state to reflect the state of the transport.
• If the client transport is a CM sender, the relay agent updates its acceptance
state to reflect the state of the transport. The sending client updates its
confirmation state to reflect the state of the relay agent.
• The transport and relay agent exchange the CM data messages that they have
been storing during the time they were disconnected.
TibrvCmTransport::create()
Method
TibrvStatus create(
TibrvTransport* transport,
const char* cmName,
tibrv_bool requestOld,
const char* ledgerName = NULL,
tibrv_bool syncLedger = TIBRV_FALSE,
const char* relayAgent = NULL);
Remarks This method creates a C certified delivery transport and stores its handle in the
C++ object.
The new certified delivery transport must employ a valid transport for network
communications.
The certified delivery transport remains valid until the program explicitly
destroys it.
(Sheet 1 of 2)
Parameter Description
transport The new TibrvCmTransport employs this transport object for network
communications.
Despite the declaration as a TibrvTransport, this object must be an instance of
TibrvNetTransport. In particular, it cannot be the TibrvProcessTransport nor
TibrvVcTransport.
cmName Bind this reusable name to the new TibrvCmTransport, so the TibrvCmTransport
represents a persistent correspondent with this name.
If non-NULL, the name must conform to the syntax rules for Rendezvous subject
names. It cannot begin with reserved tokens. It cannot be a non-reusable name
generated by another call to TibrvCmTransport::create(). It cannot be the
empty string.
If omitted or NULL, then TibrvCmTransport::create() generates a unique,
non-reusable name for the duration of the transport.
For more information, see Name on page 316.
(Sheet 2 of 2)
Parameter Description
requestOld This parameter indicates whether a persistent correspondent requires delivery of
messages sent to a previous certified delivery transport with the same name, for
which delivery was not confirmed. Its value affects the behavior of other CM
sending transports.
If this parameter is TIBRV_TRUE and cmName is non-NULL, then the new
TibrvCmTransport requires certified senders to retain unacknowledged messages
sent to this persistent correspondent. When the new TibrvCmTransport begins
listening to the appropriate subjects, the senders can complete delivery. (It is an
error to supply true when cmName is NULL.)
If this parameter is TIBRV_FALSE (or omitted), then the new TibrvCmTransport
does not require certified senders to retain unacknowledged messages. Certified
senders may delete those messages from their ledgers.
ledgerName If this argument is non-NULL, then the new TibrvCmTransport uses a file-based
ledger. The argument must represent a valid file name. Actual locations
corresponding to relative file names conform to operating system conventions. We
strongly discourage using the empty string as a ledger file name.
If omitted or NULL, then the new TibrvCmTransport uses a process-based ledger.
For more information, see Ledger File on page 316.
syncLedger If this argument is TIBRV_TRUE, then operations that update the ledger file do not
return until the changes are written to the storage medium.
If this argument is TIBRV_FALSE (or omitted), the operating system writes changes
to the storage medium asynchronously.
relayAgent Designate the rvrad process with this name as the new transport’s relay agent.
If NULL or omitted, the new TibrvCmTransport does not use a relay agent.
If non-NULL, the relay agent name must conform to the syntax rules for reusable
names. For details, see Reusable Names on page 166 in TIBCO Rendezvous Concepts.
It is illegal for a relay agent to have the same name as a CM correspondent.
We strongly discourage using the empty string as a relay agent name.
For more information, see Relay Agent on page 316.
Method Forms With only a transport, create a transient correspondent, with a unique,
non-reusable name. (Supplying NULL as the cmName has the same effect.)
All other parameters are optional, with default values when omitted.
Ledger File Every certified delivery transport stores the state of its certified communications
in a ledger.
If ledgerFile is NULL, then the new transport stores its ledger exclusively in
process-based storage. When you destroy the transport or the process terminates,
all information in the ledger is lost.
If ledgerFile specifies a valid file name, then the new transport uses that file for
ledger storage. If the transport is destroyed or the process terminates with
incomplete certified communications, the ledger file records that state. When a
new transport binds the same reusable name, it reads the ledger file and continues
certified communications from the state stored in the file.
Even though a transport uses a ledger file, it may sometimes replicate parts of the
ledger in process-based storage for efficiency; however, programmers cannot rely
on this replication.
The syncLedger parameter determines whether writing to the ledger file is a
synchronous operation:
• To specify synchronous writing, supply TIBRV_TRUE. Each time Rendezvous
software writes a ledger item, the call does not return until the data is safely
stored in the storage medium.
• To specify asynchronous writing (the default), supply TIBRV_FALSE. Certified
delivery calls may return before the data is safely stored in the storage
medium, which results in greater speed at the cost of certainty. The ledger file
might not accurately reflect program state in cases of hardware or operating
system kernel failure (but it is accurate in cases of sudden program failure).
Despite this small risk, we strongly recommend this option for maximum
performance.
A program that uses an asynchronous ledger file can explicitly synchronize it
by calling TibrvCmTransport::syncLedger() on page 340.
Destroying a transport with a file-based ledger always leaves the ledger file intact;
it neither erases nor removes a ledger file.
The ledger file must reside on the same host computer as the program that uses it.
TibrvCmTransport::createInbox()
Method
Remarks This convenience method extracts the network transport, and then calls
TibrvTransport::createInbox(). For details, see the documentation for that
method.
Parameter Description
subjectString The program supplies a string buffer, and the method
stores the new inbox subject string in that buffer.
TibrvCmTransport::destroy()
Method
TibrvStatus destroyEx(
TibrvCmTransportOnComplete* completeCB = NULL);
Remarks Destroying a certified delivery transport with a file-based ledger always leaves
the ledger file intact; it neither erases nor removes a ledger file.
This method automatically disconnects the transport from its relay agent before
destroying the object; see TibrvCmTransport::disconnectFromRelayAgent().
Parameter Description
completeCB Rendezvous software runs this completion callback
immediately after all queued tasks are complete.
Do not destroy the transport’s listeners until after this callback
signals that cleanup has completed.
See TibrvCmTransportOnComplete::onComplete on page 342.
Distributed To destroy a distributed queue transport, call destroyEx(). With the ordinary
Queue destroy call, the distributed queue can lose reliable (non-certified) task messages
before they are processed. The distributed queue needs the listeners, queues and
dispatchers (associated with the transport) to remain operational—programs
must wait until after the transport has been completely destroyed before
destroying these associated objects.
TibrvCmTransport::disallowListener()
Method
Remarks Disallowed listeners still receive subsequent messages from this sender, but
delivery is not certified. In other words:
• The listener receives a REGISTRATION.NOT_CERTIFIED advisory, informing it
that the sender has canceled certified delivery of all subjects.
• If the sender’s ledger contains messages sent to the disallowed listener (for
which this listener has not confirmed delivery), then Rendezvous software
removes those ledger items, and does not attempt to redeliver those messages.
• Rendezvous software presents subsequent messages (from the canceling
sender) to the listener without a sequence number, to indicate that delivery is
not certified.
Senders can promptly revoke the acceptance of certified delivery by calling
TibrvCmTransport::disallowListener() within the callback method that
processes the REGISTRATION.REQUEST advisory.
This method disallows a correspondent by name. If the correspondent terminates,
and another process instance (with the same reusable name) takes its place, the
new process is still disallowed by this sender.
To supersede the effect of TibrvCmTransport::disallowListener(), call
TibrvCmTransport::allowListener() on page 311.
Parameter Description
cmName Cancel certified delivery to listeners of the transport with this
name.
TibrvCmTransport::disconnectFromRelayAgent()
Method
Remarks Disconnect calls are non-blocking; they immediately return control to the
program, and asynchronously proceed with these clean-up tasks:
• If the client transport is a CM listener, the relay agent attempts to synchronize
its listening state with the transport (to assure that the relay agent adequately
represents the listening interest of the client).
• The transport stops communicating with the relay agent.
• The transport stores subsequent outbound events—including data messages
and protocol state changes. If the transport is a certified sender, it cancels its
request for delivery confirmation of outstanding unconfirmed messages. (See
also, Requesting Confirmation on page 157 in TIBCO Rendezvous Concepts.)
• The relay agent stores subsequent inbound events for the transport—
including data messages and protocol state changes.
• A transport that explicitly disconnects without terminating receives a
RELAY.DISCONNECTED advisory, informing it that is safe to sever the physical
network connection. (Terminating transports never receive this advisory;
instead, it is safe to sever the connection when the destroy call returns.)
Errors The status code TIBRV_INVALID_ARG indicates that the transport does not have a
relay agent.
TibrvCmTransport::expireMessages()
Method
Remarks This call checks the ledger for messages that match both the subject and sequence
number criteria, and immediately marks them as expired.
Once a message has expired, the CM transport no longer attempts to redeliver it
to registered listeners.
Rendezvous software presents each expired message to the sender in a
DELIVERY.FAILED advisory. Each advisory includes all the fields of an expired
message. (This call can cause many messages to expire simultaneously.)
Use with extreme caution. This call exempts the expired messages from certified
delivery semantics. It is appropriate only in very few situations.
For example, consider an application program in which an improperly formed
CM message causes registered listeners to exit unexpectedly. When the listeners
restart, the sender attempts to redeliver the offending message, which again
causes the listeners to exit. To break this cycle, the sender can expire the offending
message (along with all prior messages bearing the same subject).
Parameter Description
subject Mark messages with this subject.
Wildcards subjects are permitted, but must exactly reflect
the send subject of the message. For example, if the
program sends to A.* then you may expire messages with
subject A.* (however, A.> does not resolve to match A.*).
TibrvCmTransport::getDefaultTimeLimit()
Method
Purpose Get the default message time limit for all outbound certified messages from a
transport.
Remarks Every labeled message has a time limit, after which the sender no longer certifies
delivery.
Sending programs can explicitly set the time limit on a message (see
TibrvCmMsg::setTimeLimit() on page 351). If a time limit is not already set for
the outbound message, the transport sets it to the transport’s default time limit
(extractable with this method); if this default is not set for the transport (nor for
the message), the default time limit is zero (no time limit).
Time limits represent the minimum time that certified delivery is in effect.
Parameter Description
timeLimit The program supplies a variable, and the method stores the
time limit in that variable.
TibrvCmTransport::getLedgerName()
Method
Parameter Description
ledgerName The program supplies a variable, and the method stores the
ledger name in that variable.
Errors The status code TIBRV_ARG_CONFLICT indicates that the transport does not have a
ledger file.
TibrvCmTransport::getName()
Method
Parameter Description
cmName The program supplies a variable, and the method stores the
correspondent name in that variable.
TibrvCmTransport::getRelayAgent()
Method
Purpose Extract the name of the relay agent used by a certified delivery transport.
Parameter Description
relayAgent The program supplies a variable, and the method stores the
relay agent name in that variable.
Errors The status code TIBRV_ARG_CONFLICT indicates that the transport does not have a
relay agent.
TibrvCmTransport::getRequestOld()
Method
Purpose Extract the request old messages flag of a certified delivery transport.
Parameter Description
requestOld The program supplies a variable, and the method stores the
request old messages flag name in that variable.
TibrvCmTransport::getSyncLedger()
Method
Parameter Description
syncLedger The program supplies a variable, and the method stores the
sync ledger flag name in that variable.
Errors The status code TIBRV_ARG_CONFLICT indicates that the transport does not have a
ledger file.
TibrvCmTransport::getTransport()
Method
TibrvCmTransport::removeListener()
Method
Remarks This method cancels certified delivery of the specific subject to the
correspondent with this name. The listening correspondent may subsequently
re-register for certified delivery of the subject. (In contrast,
TibrvCmTransport::disallowListener() cancels certified delivery of all
subjects to the correspondent, and prohibits re-registration.)
Senders can call this method when the ledger item for a listening correspondent
has grown very large. Such growth indicates that the listener is not confirming
delivery, and may have terminated. Removing the listener reduces the ledger size
by deleting messages stored for the listener.
When a sending program calls this method, certified delivery software in the
sender behaves as if the listener had closed the endpoint for the subject. The
sending program deletes from its ledger all information about delivery of the
subject to the correspondent with this cmName. The sending program receives a
REGISTRATION.CLOSED advisory, to trigger any operations in the callback method
for the advisory.
If the listening correspondent is available (running and reachable), it receives a
REGISTRATION.NOT_CERTIFIED advisory, informing it that the sender no longer
certifies delivery of the subject.
If the correspondent with this name does not receive certified delivery of the
subject from this sender TibrvCmTransport, then
TibrvCmTransport::removeListener() the status code
TIBRV_INVALID_SUBJECT.
Parameter Description
cmName Cancel certified delivery of the subject to listeners of this
correspondent.
TibrvCmTransport::removeSendState()
Method
Background In some programs subject names are useful only for a limited time; after that time,
they are never used again. For example, consider a server program that sends
certified reply messages to client inbox names; it only sends one reply message to
each inbox, and after delivery is confirmed and complete, that inbox name is
obsolete. Nonetheless, a record for that inbox name remains in the server’s ledger.
As such obsolete records accumulate, the ledger size grows. To counteract this
growth, programs can use this method to discard obsolete subject records from
the ledger.
The DELIVERY.COMPLETE advisory is a good opportunity to clear the send state of
an obsolete subject. Another strategy is to review the ledger periodically,
sweeping to detect and remove all obsolete subjects.
Do not use this method to clear subjects that are still in use.
Parameter Description
subject Remove send state for this obsolete subject.
Remarks As a side-effect, this method resets the sequence numbering for the subject, so the
next message sent on the subject would be number 1. In proper usage, this
side-effect is never detected, since obsolete subjects are truly obsolete.
TibrvCmTransport::reviewLedger()
Method
Purpose Query the ledger for stored items related to a subject name.
Remarks The callback method receives one message for each matching subject of outbound
messages stored in the ledger. For example, when FOO.* is the subject,
TibrvCmTransport::reviewLedger() calls its callback method separately for
each matching subject—once for FOO.BAR, once for FOO.BAZ, and once for
FOO.BOX.
Parameter Description
reviewCallback This object receives the review messages.
TibrvCmTransport::send()
Method
Remarks This method sends the message, along with its certified delivery protocol
information: the correspondent name of the TibrvCmTransport, a sequence
number, and a time limit. The protocol information remains on the message
within the sending program, and also travels with the message to all receiving
programs.
Programs can explicitly set the message time limit; see
TibrvCmMsg::setTimeLimit() on page 351. If a time limit is not already set for
the outbound message, this method sets it to the transport’s default time limit (see
TibrvCmTransport::setDefaultTimeLimit() on page 338); if that default is not
set for the transport, the default time limit is zero (no time limit).
Parameter Description
msg Send this message.
Wildcard subjects are illegal.
TibrvCmTransport::sendReply()
Method
Remarks This convenience call extracts the reply subject of an inbound request message,
and sends a labeled outbound reply message to that subject. In addition to the
convenience, this call is marginally faster than using separate calls to extract the
subject and send the reply.
This method can send a labeled reply to an ordinary message.
This method automatically registers the requesting CM transport, so the reply
message is certified.
Parameter Description
replyMsg Send this outbound reply message.
requestMsg Send a reply to this inbound request message; extract its reply
subject to use as the subject of the outbound reply message.
If this message has a wildcard reply subject, the method
produces an error.
Give special attention to the order of the arguments to this method. Reversing the
inbound and outbound messages can cause an infinite loop, in which the program
repeatedly resends the inbound message to itself (and all other recipients).
TibrvCmTransport::sendRequest()
Method
This call blocks all other activity on its program thread. If appropriate,
programmers must ensure that other threads continue dispatching events on its
queues.
Parameter Description
requestMsg Send this request message.
Wildcard subjects are illegal.
replyMsg The program supplies a variable, and the method stores the
inbound reply in that variable.
The program need not create the reply message, nor allocate
space for it. However, the program must destroy the reply
message, even though it did not create it.
timeout Maximum time (in seconds) that this call can block while
waiting for a reply.
TIBRV_WAIT_FOREVER (-1) indicates no timeout (wait without
limit for a reply).
Remarks Programs that receive and process the request message cannot determine that the
sender has blocked until a reply arrives.
The sender and receiver must already have a certified delivery agreement,
otherwise the request is not certified.
The request message must have a valid destination subject; see
TibrvMsg::setSendSubject() on page 96.
A certified request does not necessarily imply a certified reply; the replying
program determines the type of reply message that it sends.
TibrvCmTransport::setDefaultTimeLimit()
Method
Purpose Set the default message time limit for all outbound certified messages from a
transport.
Remarks Every labeled message has a time limit, after which the sender no longer certifies
delivery.
Sending programs can explicitly set the time limit on a message (see
TibrvCmMsg::setTimeLimit() on page 351). If a time limit is not already set for
the outbound message, the transport sets it to the transport’s default time limit
(set with this method); if this default is not set for the transport, the default time
limit is zero (no time limit).
Time limits represent the minimum time that certified delivery is in effect.
Parameter Description
timeLimit Use this time limit (in whole seconds). The time limit must be
non-negative.
TibrvCmTransport::setPublisherInactivityDiscardInterval()
Method
Purpose Set a time limit after which a listening CM transport can discard state for inactive
CM senders.
Remarks The timeout value limits the time that can elapse during which such a sender does
not send a message. When the elapsed time exceeds this limit, the listening
transport declares the sender inactive, and discards internal state corresponding
to the sender.
We discourage programmers from using this call except to solve a very specific
problem, in which a long-running CM listener program accumulates state for a
large number of obsolete CM senders with non-reusable names.
Before using this call, review every subject for which the CM transport has a
listener; ensure that only CM senders with non-reusable names send to those
subjects. (If senders with reusable names send messages to such subjects, the
listening transport can discard their state, and incorrect behavior can result.)
Parameter Description
timeout Use this time limit (in whole seconds). The time limit must be
non-negative.
TibrvCmTransport::syncLedger()
Method
Remarks When this method returns, the transport’s current state is safely stored in the
ledger file.
Transports that use synchronous ledger files need not call this method, since the
current state is automatically written to the storage medium before returning.
Transports that use process-based ledger storage need not call this method, since
they have no ledger file.
Errors The status code TIBRV_INVALID_ARG indicates that the transport does not have a
ledger file.
TibrvCmTransportOnComplete
Class
TibrvCmTransportOnComplete::onComplete
Method
Remarks Programs must not destroy the transport’s listeners, nor any queue nor dispatcher
that pertains to the transport, until after this callback signals that cleanup has
completed.
Parameter Description
destroyedTransport This parameter receives the transport object.
However, by the time this method runs, the transport is already destroyed;
this method cannot use the transport object in Rendezvous calls.
TibrvCmReviewCallback
Class
TibrvCmReviewCallback::onLedgerMsg()
Method
Parameter Description
cmTransport This parameter receives the transport.
subject This parameter receives the subject for this ledger item.
Message This callback method receives ledger summary messages with these fields.
Content
(Sheet 1 of 2)
(Sheet 2 of 2)
total_size The total storage (in bytes) occupied by all messages with this
subject name.
If the ledger contains several messages with this subject name,
then this field sums the storage space over all of them.
This field has datatype TIBRVMSG_U64.
listener Each summary message can contain one or more fields named
listener. Each listener field contains a nested submessage with
details about a single registered listener.
This field has datatype TIBRVMSG_MSG.
listener.name Within each listener submessage, the name field contains the
name of the listener transport.
This field has datatype TIBRVMSG_STRING.
TibrvCmMsg
Class
Remarks This class is a collection of accessor methods. Programs do not create instances of
TibrvCmMsg. Instead, programs use its static methods to get and set certified
delivery information of TibrvMsg objects.
TibrvCmMsg::getSender()
Method
Purpose Extract the correspondent name of the sender from a certified message.
Parameter Description
msg Extract the sender name from this message.
name The program supplies a variable. The method stores the name in
that variable.
Status This method returns a status code that discriminates between labeled messages
and other messages.
• If the message is from a CM sender, then TibrvCmMsg::getSender() returns
the status code TIBRV_OK and yields a valid CM correspondent name.
• If the message is not from a CM sender, then TibrvCmMsg::getSender()
returns the status code TIBRV_NOT_FOUND.
TibrvCmMsg::getSequence()
Method
Parameter Description
msg Extract the sequence number from this message.
Status This method returns a status code that discriminates between certified messages
(with a certified delivery agreement) and other messages.
• If the message is from a CM sender, and the CM listener is registered for
certified delivery with that sender, then TibrvCmMsg::getSequence()
returns the status code TIBRV_OK and yields a valid sequence number.
• If the message is from a CM sender, but the listener is not registered for
certified delivery, then TibrvCmMsg::getSequence() in the context of a
TibrvCmMsgCallback::onCmMsg() method returns the status code
TIBRV_NOT_FOUND. (In any other context, it returns the actual sequence
number stored on the message.)
Notice that the first labeled message that a program receives on a subject
might not be certified; that is, the sender has not registered a certified delivery
agreement with the listener. If appropriate, the certified delivery library
automatically requests that the sender register the listener for certified
delivery. (See Discovery and Registration for Certified Delivery on page 154 in
TIBCO Rendezvous Concepts.)
A labeled but uncertified message can also result when the sender explicitly
disallows or removes the listener.
• If the message is not from a CM sender, then TibrvCmMsg::getSequence()
(in any context) returns the status code TIBRV_NOT_FOUND.
TibrvCmMsg::getTimeLimit()
Method
Remarks Programs can explicitly set the message time limit (see
TibrvCmMsg::setTimeLimit() on page 351).
Parameter Description
msg Extract the time limit from this message.
timeLimit The program supplies a variable. The method stores the time
limit in that variable.
TibrvCmMsg::setTimeLimit()
Method
Remarks Every labeled message has a time limit, after which the sender no longer certifies
delivery.
Sending programs can explicitly set the message time limit using this method. If a
time limit is not already set for the outbound message,
TibrvCmTransport::send() sets it to the transport’s default time limit (see
TibrvCmTransport::setDefaultTimeLimit() on page 338); if that default is not
set for the transport, the default time limit is zero (no time limit).
Time limits represent the minimum time that certified delivery is in effect.
It is meaningless for receiving programs to call this method.
Parameter Description
msg Set the time limit of this message.
timeLimit Use this time limit (in whole seconds) for the message. The
time limit must be non-negative.
TibrvCmMsgCallback
Class
TibrvCmMsgCallback::onCmMsg()
Method
Parameter Description
cmListener This parameter receives the listener event.
CM Label The callback method for certified delivery messages can use CM label information
Information to discriminate these situations:
• If TibrvCmMsg::getSender() returns status code TIBRV_NOT_FOUND, then the
message uses the reliable protocol (that is, it was sent from an ordinary
transport).
• If TibrvCmMsg::getSender() returns a valid sender name, then the message
uses the certified delivery protocol (that is, it is a labeled message, sent from a
CM transport).
Once the callback method determines that the message uses the certified
delivery protocol, it can discriminate further:
— If TibrvCmMsg::getSequence() returns status code TIBRV_NOT_FOUND,
then the listener is not registered for certified delivery from the sender.
— If TibrvCmMsg::getSequence() returns TIBRV_OK, then a certified
delivery agreement is in effect for this subject with the sender.
Programs can use distributed queues for one of n certified delivery to a group of
worker processes.
A distributed queue is a group of TibrvCmQueueTransport objects, each in a
separate process. From the outside, a distributed queue appears as though a
single transport object; inside, the group members act in concert to process
inbound task messages. Ordinary transports and CM transports can send task
messages to the group. Notice that the senders are not group members, and do
not do anything special to send messages to a group; rather, they send messages
to ordinary subject names. Inside the group, the member acting as scheduler
assigns each task message to exactly one of the other members (which act as
workers); only that worker processes the task message. Each member uses CM
listener objects to receive task messages.
Distributed queues depend upon the certified delivery methods and the fault
tolerance methods.
Topics
TibrvCmQueueTransport
Class
(Sheet 1 of 2)
Inherited Methods
Legal Methods TibrvCmTransport::getName()
TibrvCmTransport::getTransport()
TibrvTransport::destroy()
TibrvTransport::isValid()
TibrvTransport::getHandle()
TibrvTransport::setDescription()
(Sheet 2 of 2)
Inherited Methods
Disabled Methods TibrvCmTransport::addListener()
TibrvCmTransport::allowListener()
TibrvCmTransport::connectToRelayAgent()
TibrvCmTransport::disallowListener()
TibrvCmTransport::disconnectFromRelayAgent()
TibrvCmTransport::getDefaultTimeLimit()
TibrvCmTransport::getLedgerName()
TibrvCmTransport::getRelayAgent()
TibrvCmTransport::getRequestOld()
TibrvCmTransport::getSyncLedger()
TibrvCmTransport::removeListener()
TibrvCmTransport::removeSendState()
TibrvCmTransport::reviewLedger()
TibrvCmTransport::send()
TibrvCmTransport::sendReply()
TibrvCmTransport::sendRequest()
TibrvCmTransport::setDefaultTimeLimit()
TibrvCmTransport::syncLedger()
TibrvTransport::createInbox()
TibrvTransport::send()
TibrvTransport::sendReply()
TibrvTransport::sendRequest()
TibrvCmQueueTransport::create()
Method
Remarks This method creates a new C distributed queue member, and stores it in the C++
object.
The new TibrvCmQueueTransport must employ a valid TibrvTransport for
network communications.
(Sheet 1 of 3)
Parameter Description
transport The new TibrvCmQueueTransport employs this TibrvTransport object
for network communications.
Destroying the TibrvCmQueueTransport does not affect this transport.
cmName Bind this reusable name to the new transport object, which becomes a
member of the distributed queue with this name.
The name must be non-NULL, and conform to the syntax rules for
Rendezvous subject names. It cannot begin with reserved tokens. It
cannot be a non-reusable name generated by a call to
TibrvCmTransport::create(). It cannot be the empty string.
(Sheet 2 of 3)
Parameter Description
workerWeight When the scheduler receives a task, it assigns the task to the available
worker with the greatest worker weight.
A worker is considered available unless either of these conditions are
true:
• The pending tasks assigned to the worker member exceed its task
capacity.
• The worker is also the scheduler. (The scheduler assigns tasks to its
own worker role only when no other workers are available.)
When omitted, the default value is 1.
workerTasks Task capacity is the maximum number of tasks that a worker can accept.
When the number of accepted tasks reaches this maximum, the worker
cannot accept additional tasks until it completes one or more of them.
When the scheduler receives a task, it assigns the task to the worker with
the greatest worker weight—unless the pending tasks assigned to that
worker exceed its task capacity. When the preferred worker has too
many tasks, the scheduler assigns the new inbound task to the worker
with the next greatest worker weight.
When omitted, the default value is 1. Value must be greater than zero.
schedulerWeight Weight represents the ability of this member to fulfill the role of
scheduler, relative to other members with the same name. Cooperating
members use relative scheduler weight values to elect one member as the
scheduler; members with higher scheduler weight take precedence.
When omitted, the default value is 1.
Acceptable values range from 0 to 65535. Zero is a special value,
indicating that the member can never be the scheduler. For more
information, see Rank and Weight on page 204 in TIBCO Rendezvous
Concepts.
(Sheet 3 of 3)
Parameter Description
schedulerHeartbeat The scheduler sends heartbeat messages at this interval (in seconds).
All TibrvCmQueueTransport objects with the same name must specify
the same value for this parameter. The value must be strictly positive. To
determine the correct value, see Step 4: Choose the Intervals on page 235
in TIBCO Rendezvous Concepts.
When omitted, the default value is 1.0.
schedulerActivation When the heartbeat signal from the scheduler has been silent for this
interval (in seconds), the cooperating member with the greatest
scheduler weight takes its place as the new scheduler.
All TibrvCmQueueTransport objects with the same name must specify
the same value for this parameter. The value must be strictly positive. To
determine the correct value, see Step 4: Choose the Intervals on page 235
in TIBCO Rendezvous Concepts.
When omitted, the default value is 3.5.
Constant Value
TIBRVCM_DEFAULT_COMPLETE_TIME 0
TIBRVCM_DEFAULT_WORKER_WEIGHT 1
TIBRVCM_DEFAULT_WORKER_TASKS 1
TIBRVCM_DEFAULT_SCHEDULER_WEIGHT 1
TIBRVCM_DEFAULT_SCHEDULER_HB 1.0
TIBRVCM_DEFAULT_SCHEDULER_ACTIVE 3.5
TibrvCmQueueTransport::destroy()
Method
TibrvCmQueueTransport::getCompleteTime()
Method
Purpose Extract the worker complete time limit of a distributed queue member.
Parameter Description
completeTime The program supplies a variable, and the method stores
the worker complete time in that variable.
TibrvCmQueueTransport::getUnassignedMessageCount()
Function
Purpose Extract the number of unassigned task messages from a distributed queue
transport.
Remarks An unassigned task message is a message received by the scheduler, but not yet
assigned to any worker in the distributed queue.
This call produces a valid count only within a scheduler process. Within a worker
process, this call always produces zero.
Parameter Description
msgCount The program supplies a variable, and the function stores the
unassigned task count in that variable.
TibrvCmQueueTransport::getWorkerWeight()
Method
Parameter Description
workerWeight The program supplies a variable, and the method stores
the worker weight in that variable.
TibrvCmQueueTransport::getWorkerTasks()
Method
Parameter Description
workerTasks The program supplies a variable, and the method stores
the worker task capacity in that variable.
TibrvCmQueueTransport::setCompleteTime()
Method
Purpose Set the worker complete time limit of a distributed queue member.
Remarks If the complete time is non-zero, the scheduler waits for a worker member to
complete an assigned task. If the complete time elapses before the scheduler
receives completion from the worker member, the scheduler reassigns the task to
another worker member.
Zero is a special value, which specifies no limit on the completion time—that is,
the scheduler does not set a timer, and does not reassign tasks when task
completion is lacking. All members implicitly begin with a default complete time
value of zero; programs can change this parameter using this method.
Parameter Description
completeTime Use this complete time (in seconds). The time must be
non-negative.
TibrvCmQueueTransport::setTaskBacklogLimit...()
Method
TibrvStatus setTaskBacklogLimitInMessages(
tibrv_u32 msgLimit);
Purpose Set the scheduler task queue limits of a distributed queue transport.
Remarks The scheduler stores tasks in a queue. These properties limit the maximum size of
that queue—by number of bytes or number of messages (or both). When no value
is set for these properties, the default is no limit.
When the task messages in the queue exceed either of these limits, Rendezvous
software deletes new inbound task messages.
Programs may call each of these methods at most once. Those calls must occur
before the transport assumes the scheduler role; after a transport acts as a
scheduler, these values are fixed, and subsequent attempts to change them result
in status code TIBRV_NOT_PERMITTED.
Parameter Description
byteLimit Use this size limit (in bytes).
Zero is a special value, indicating no size limit.
TibrvCmQueueTransport::setWorkerWeight()
Method
Remarks Relative worker weights assist the scheduler in assigning tasks. When the
scheduler receives a task, it assigns the task to the available worker with the
greatest worker weight.
The default worker weight is 1; programs can set this parameter at creation using
TibrvCmQueueTransport::create(), or change it dynamically using this
method.
Parameter Description
workerWeight Use this worker weight.
TibrvCmQueueTransport::setWorkerTasks()
Method
Remarks Task capacity is the maximum number of tasks that a worker can accept. When
the number of accepted tasks reaches this maximum, the worker cannot accept
additional tasks until it completes one or more of them.
When the scheduler receives a task, it assigns the task to the worker with the
greatest worker weight—unless the pending tasks assigned to that worker exceed
its task capacity. When the preferred worker has too many tasks, the scheduler
assigns the new inbound task to the worker with the next greatest worker weight.
The default worker task capacity is 1.
Parameter Description
workerTasks Use this task capacity. Value must be greater than zero.
Chapter 11 Datatypes
Topics
Scalar Types
(Sheet 2 of 2)
Array Types
C Datatypes
(Sheet 1 of 2)
(Sheet 2 of 2)
Datatype Conversion
General Rules
These general rules govern most conversions.
Supported
• All wire format types decode to the homologous C datatypes (in get calls), and
all C datatypes encode to the homologous wire format types (in add and update
calls).
• All wire format numeric scalar types convert to all C numeric scalar types.
• All wire format numeric array types convert to all C numeric array types.
Caution
• Converting a wire format opaque or XML byte sequence to a C character
string creates a printable string, but the string does not capture any of the
opaque data bytes (it captures only the number of bytes).
• Converting a wire format signed integer to a C unsigned integer discards the
sign.
• Converting a wire format numeric type to a C numeric type with fewer bits
risks loss of precision.
• Converting wire format floating point numbers to C integer types discards the
fractional part.
Not Supported
• Array types do not convert to scalar types.
• Scalar types do not convert to array types.
• C types do not convert to non-homologous wire format types (when adding
or updating a field).
Converting to Boolean
• When converting a string to a boolean, all strings in which the first character is
either t or T map to boolean true. All other strings map to boolean false.
• When converting a numeric value to a boolean, zero maps to boolean false.
All non-zero numeric values map to boolean true.
Get
tibrvMsgDateTime
tibrv_ipaddr32
tibrv_ipport16
tibrv_u16[]
tibrv_u32[]
tibrv_u64[]
tibrv_f32[]
tibrv_f64[]
tibrv_i16[]
tibrv_i32[]
tibrv_i64[]
tibrvMsg[]
tibrv_bool
tibrv_u16
tibrv_u32
tibrv_u64
tibrv_u8[]
tibrv_f32
tibrv_f64
tibrvMsg
tibrv_i16
tibrv_i32
tibrv_i64
tibrv_i8[]
tibrv_u8
tibrv_i8
char*[]
char*
void*
TIBRVMSG_BOOL S S S S S S S S S S S
TIBRVMSG_F32 S N N N N N N N N N S
TIBRVMSG_F64 S N N N N N N N N N S
TIBRVMSG_I8 S N N N N N N N N N S
TIBRVMSG_I16 S N N N N N N N N N S
TIBRVMSG_I32 S N N N N N N N N N S
TIBRVMSG_I64 S N N N N N N N N N S
TIBRVMSG_U8 S N N N N N N N N N S
TIBRVMSG_U16 S N N N N N N N N N S
TIBRVMSG_U32 S N N N N N N N N N S
TIBRVMSG_U64 S N N N N N N N N N S
tibrvMsg Source Type
TIBRVMSG_IPADDR32 N S
TIBRVMSG_IPPORT16 N N N S
TIBRVMSG_DATETIME C
TIBRVMSG_F32ARRAY N N N N N N N N N S
TIBRVMSG_F64ARRAY N N N N N N N N N S
TIBRVMSG_I8ARRAY N N N N N N N N N S
TIBRVMSG_I16ARRAY N N N N N N N N N S
TIBRVMSG_I32ARRAY N N N N N N N N N S
TIBRVMSG_I64ARRAY N N N N N N N N N S
TIBRVMSG_U8ARRAY N N N N N N N N N S
TIBRVMSG_U16ARRAY N N N N N N N N N S
TIBRVMSG_U32ARRAY N N N N N N N N N S
TIBRVMSG_U64ARRAY N N N N N N N N N S
TIBRVMSG_MSG S
TIBRVMSG_OPAQUE C
TIBRVMSG_STRING P P P P P P P P P P P P P
TIBRVMSG_XML C
TIBRVMSG_MSGARRAY
TIBRVMSG_STRINGARRAY
Key
Homologous types; conversion always supported; no loss of information
S Supported conversion; always supported
N Numeric conversion; loss of information is possible (without warning)
P Parsed conversion; supported only when sensible and syntactically correct
C Caution; supported, but results sometimes can be misleading
Unsupported conversion
Topics
TibrvStatus
Class
(Sheet 1 of 5)
Constant Description
TIBRV_OK The method returned without error.
(Sheet 2 of 5)
Constant Description
TIBRV_NETWORK_NOT_FOUND TibrvNetTransport::create() cannot match the network
name using getnetbyname().
TIBRV_INVALID_NAME The field name is too long; see Field Name Length on page 48.
TIBRV_INVALID_SIZE The explicit size in the field does not match its explicit type.
TIBRV_INVALID_COUNT The explicit field count does not match its explicit type.
TIBRV_NOT_FOUND The method could not find the specified field in the message.
(Sheet 3 of 5)
Constant Description
TIBRV_ID_IN_USE Cannot add this field because its identifier is already present
in the message; identifiers must be unique.
TIBRV_CONVERSION_FAILED The method found the specified field, but could not convert it
to the desired datatype.
TIBRV_INVALID_INSTANCE The program supplied zero as the field instance number (the
first instance is number 1).
TIBRV_INVALID_DISPATCHABLE The method received an event queue or queue group that has
been destroyed, or is otherwise unusable.
(Sheet 4 of 5)
Constant Description
TIBRV_INVALID_EVENT The method received an event that has been destroyed, or is
otherwise unusable.
TIBRV_INVALID_QUEUE_GROUP The method received a queue group that has been destroyed,
or is otherwise unusable.
TIBRV_INVALID_IO_SOURCE The method received an invalid I/O source (for this operating
system).
TIBRV_NOT_FILE_OWNER The program cannot open the specified file because another
program owns it.
For example, ledger files are associated with correspondent
names.
(Sheet 5 of 5)
Constant Description
TIBRV_IO_FAILED Cannot write to ledger file.
TibrvStatus::getCode()
Method
TibrvStatus::getText()
Method
Index
A C object
TibrvDispatchable 180
accept, create virtual circuit 254 TibrvDispatcher 218
action, fault tolerance 261 TibrvEvent 129
activate, fault tolerance 261 TibrvFtMember 270
add message field TibrvFtMonitor 288
array 51 TibrvMsg 83
datetime 57 TibrvQueue 191
nested message 53 TibrvQueueGroup 209
opaque bytes 55 TibrvTransport 230
scalar 49 callback method
XML 56 destroy complete
add() queue to group 205 CM transport 342
addField() to message 47 event 140
addListener() to CM transport 310 fault tolerance 280
advisory message, see TIBCO Rendezvous Concepts monitor 295
allow listener, CM 311 queue 202
array fault tolerance 277
add 51 monitor 293
get 72 generic 138
update 102 I/O event 176
inbound CM message 353
inbound message 150
inbound message vector 160
B review ledger 344
timer 168
backward compatibility. See release 5. certificate
batch mode 249 set daemon certificate 27
batch mode (type) 239 set user certificate 29, 30
bytes, get field as 63 certified delivery 297
add listener 310
allow listener 311
confirm 300
C
C datatypes 374
J
H
join a fault tolerance group 264
header files 8
L string 54
XML 56
ledger callback method 150
file 316 vector 160
name, get 324 certified delivery 346
review 333 convert to string 59
sync 340 copy 60
get property 328 create 44
library files 9 destructor 46
licensed transport 245 detach 61
limit policy expand 62
constants 184 field (as a class) 109
get 192 get data as a byte sequence 63, 64
set 197 get field 67
linking 9 array 72
listener 143 datetime 78
CM 298 nested message 74
create 146 opaque bytes 76
CM 301 scalar 70
vector 152 string 75
destroy 127 XML 77
CM 302 get field by index 80
subject, get 147 get field instance 81
CM 303 ownership and control
transport, get 148 detach() 61
CM 304 isDetatched() 88
vector 151 references
create 152 clear 58
loop, get field by index mark 89
lost interval 284 remove field 91
reply subject 85, 95
reset 94
send 234
M send subject 86, 96
size 65
mark references 89 update field 97
member, fault tolerance 262 array 102
callback 277 datetime 108
message 41 nested message 104
add field 47 opaque bytes 106
array 51 scalar 100
datetime 57 string 105
nested message 53 XML 107
opaque bytes 55
scalar 49
V
valid
CM listener 305
dispatcher 220
event 135
event queue 195
fault tolerance member 274
fault tolerance monitor 291
message data 34
queue group 210
transport 231
vector callback 159
vector listener 151
create 152
subject, get 157
transport, get 158
version() 25
virtual circuit
transport class 252
wait for connection 257