Professional Documents
Culture Documents
User’s Guide
Software Release 5.1
October 2000
Important Information
The information contained in this document is subject to U.S. and international copyright laws and
treaties and all rights are reserved. No part of this document may be reproduced in any form
without the written authorization of an officer of TIBCO Software Inc.
Technologies described herein are covered by existing patents and pending patent applications.
TIB, TIBCO, TIB/ActiveEnterprise and Information Bus are registered trademarks in the US and
other countries.
All brand and product names are trademarks or registered trademarks of their respective holders.
THIS PUBLICATION 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.
READ THIS END USER LICENSE AGREEMENT Additional Licenses. If Customer desires to increase the
CAREFULLY. BY DOWNLOADING OR INSTALLING THE number of Permitted Instances, Customer may request the
SOFTWARE, YOU AGREE TO BE BOUND BY THIS same by submission of an additional Ordering Document and
AGREEMENT. IF YOU DO NOT AGREE TO THESE upon acceptance by TIBCO, Customer shall be permitted to
TERMS, DO NOT DOWNLOAD OR INSTALL THE deploy such additional Permitted Instances, all of which shall
SOFTWARE AND RETURN IT TO THE VENDOR FROM otherwise be subject to the terms of this Agreement.
WHICH IT WAS PURCHASED. RETURNS BY THE
ORIGINAL PURCHASER WITHIN THIRTY (30) DAYS OF Technical Support. Provided Customer has paid applicable
THE PURCHASE DATE WILL RECEIVE A FULL support fees (not included with Software fees unless
REFUND. separately listed), TIBCO shall provide support for generally
available TIBCO Software on an annual basis commencing
Upon acceptance, the following shall govern your use of on the Purchase Date, as follows (“Support”): Customer shall
the Software except to the extent all or any portion of the designate as technical support contacts that number of
Customer’s employees as are permitted under the level of
Software (a) is subject to a separate written agreement, Support purchased (contacts are changeable upon 48-hours
(b) includes a separate “click-on” license agreement as prior written notice to TIBCO). Each contact may contact
part of the download or installation process, or (c) is TIBCO for problem resolution during TIBCO’s published
provided by a third party under the terms set forth in an support hours corresponding to the level of Support fees
paid.
addenda at the end of this Agreement, in which case the
terms of such addenda shall control over inconsistent Upon notice from a contact of a Software problem which can
terms with regard to such portion(s). be reproduced at a TIBCO support facility or via remote
access to Customer’s facility, TIBCO shall use reasonable
efforts to correct or circumvent the problem according to its
License Grant. The Software is the property of TIBCO or
published support objectives. TIBCO reserves the right to
its licensors and is protected by copyright and other laws.
make changes only to the most currently available version.
While TIBCO continues to own the Software, TIBCO
TIBCO will use reasonable efforts to support the previously
hereby grants to Customer a limited, non-transferable,
released version of the Software for a maximum of six
non-exclusive, license to use the number of Permitted
months. Software may be transferred to another site or
Instances set forth in the Ordering Document, in
operating system only upon written notice to TIBCO and
machine-readable, object code form and solely for
subject to TIBCO’s transfer policies and fees then in effect.
Customer’s internal business use.
Software may be transferred without notice or additional cost
from one machine to another at the same site if the second
Restrictions. Customer agrees not to (a) make more
machine runs the same operating system software and
copies than the number of Permitted Instances plus a
otherwise there is no increase in the Permitted Instances.
reasonable number of backups; (b) provide access to the
Software to anyone other than employees, contractors, or
TIBCO shall have no obligation to support the Software (i) for
consultants of Customer; (c) sublicense, transfer, assign,
use on any computer system running other than the operating
distribute to any third party, pledge, lease, rent, or
system software for which the Software is approved (as set
commercially share the Software or any of Customer’s
forth in the Software documentation) and licensed hereunder,
rights under this Agreement; (d) use the Software for
or (ii) if Customer has modified the Software in breach of this
purposes of providing a service bureau, including, without
Agreement. TIBCO shall have no obligation to modify any
limitation, providing third-party hosting, or third-party
version of the Software to run with any new versions of any
application integration or application service provider-type
operating system, or any other third party software or
services, or any similar services; (e) use the Software in
hardware. If Customer purchases Support for any Software,
connection with ultrahazardous activities, or any activity for
Customer must purchase the same level of Support for all
which failure of the Software might result in death or
copies of the Software for which it is licensed.
serious bodily injury to Customer or a third party; or (f)
directly or indirectly, in whole or in part, modify, translate,
Support may be extended for one year periods on the
reverse engineer, decrypt, decompile, disassemble, make
anniversary of each Purchase Date at the standard amounts
error corrections to, create derivative works based on, or
set forth in its price list, for as long as TIBCO offers Support.
otherwise attempt to discover the source code or
Customer may reinstate lapsed support for any then currently
underlying ideas or algorithms of the Software.
supported Software by paying all Support fees in arrears and
any applicable reinstatement fee. Upgrades, patches,
Beta and Evaluation Licenses. Notwithstanding the
enhancements, bug fixes, new versions and/or new releases
foregoing, if the Software is being provided for
of the Software provided from time to time under Support
demonstration, beta testing, or evaluation purposes, then
shall be used only as replacements to existing Permitted
Customer agrees (a) to use the Software solely for such
Instances, and shall not be deemed to increase that number,
purposes, (b) that the Software will not be used or
and use thereof shall be governed by the terms of this
deployed in a production environment, and (c) that such
Agreement, except for the first paragraph of the Limited
use shall automatically terminate upon the earlier of thirty
Warranty and any right of return or refund.
days from the date Customer receives the right to install
the Software, or Customer’s receipt of notice of
Consulting Services. Customer may request additional
termination from TIBCO.
services (“Services”) either in an Ordering Document, or by a
separate mutually executed work order, statement of work or
other work-request document incorporating this Agreement Limitation of Liability. IN NO EVENT WILL TIBCO BE LIABLE
(each, a “Work Order”). Unless otherwise expressly agreed to in a FOR ANY LOST DATA, LOST REVENUE, LOST PROFITS,
Work Order, all Services and any work product therefrom shall be DAMAGE TO REPUTATION, BUSINESS INTERRUPTION, OR
(a) performed on a time and materials basis, plus meals, lodging, ANY OTHER INDIRECT, INCIDENTAL, CONSEQUENTIAL,
travel, and other expenses reasonably incurred in connection SPECIAL, PUNITIVE, EXEMPLARY OR ANY SIMILAR TYPE
therewith, (b) deemed accepted upon delivery, and (c) exclusively DAMAGES ARISING OUT OF THIS AGREEMENT, THE USE OR
owned by TIBCO (except for confidential information of Customer THE INABILITY TO USE THE SOFTWARE, OR THE
identified to TIBCO in the Ordering Document), including all right, PROVISION OF ANY SUPPORT OR SERVICES, EVEN IF
title and intellectual property or other right or interest therein. TIBCO HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
Each Work Order is intended to constitute an independent and DAMAGES.
distinct agreement of the parties, notwithstanding that each shall
be construed to incorporate all applicable provisions of this IN NO EVENT SHALL TIBCO'S LIABILITY TO CUSTOMER,
Agreement. Fees for Services shall be due and payable in United WHETHER IN CONTRACT, TORT (INCLUDING ACTIVE OR
States dollars net30 from the date of TIBCO’s invoice. PASSIVE NEGLIGENCE), BREACH OF WARRANTY, CLAIMS
BY THIRD PARTIES OR OTHERWISE, EXCEED THE PRICE
Limited Warranty. If Customer obtained the Software directly PAID BY CUSTOMER UNDER THE APPLICABLE ORDERING
from TIBCO, then TIBCO warrants that for a period of thirty (30) DOCUMENT.
days from the Purchase Date: (i) the media on which the Software
is furnished will be free of defects in materials and workmanship THE FOREGOING LIMITATIONS SHALL APPLY EVEN IF THE
under normal use; and (ii) the Software will substantially conform ABOVE-STATED REMEDY OR LIMITED WARRANTY FAILS OF
to its published specifications. This limited warranty extends only ITS ESSENTIAL PURPOSE. BECAUSE SOME STATES OR
to the original Customer hereunder. Customer’s sole and JURISDICTIONS DO NOT ALLOW LIMITATION OR EXCLUSION
exclusive remedy and the entire liability of TIBCO and its OF CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE
suppliers under this limited warranty will be, at TIBCO’s option, ABOVE LIMITATION MAY NOT APPLY TO CUSTOMER.
repair, replacement, or refund of the Software and applicable
Support fees, in which event this Agreement shall terminate upon Confidentiality. Aspects of the Software, Support and Services,
payment thereof. including the specific design and structure thereof, constitute
trade secrets and/or copyrighted material of TIBCO and
This warranty does not apply to any Software which (a) is Customer agrees not to disclose, provide, or otherwise make
licensed for beta, evaluation, testing or demonstration purposes available the same in any form to any third party. Customer
for which TIBCO does not receive a license fee, (b) has been agrees to implement reasonable security measures to protect
altered or modified, except by TIBCO, (c) has not been installed, trade secrets and copyrighted material and to affix to all copies of
operated, repaired, or maintained in accordance with instructions Software or other confidential or trade secret information,
supplied by TIBCO, (d) has been subjected to abnormal physical appropriate TIBCO copyright, confidentiality, and proprietary
or electrical stress, misuse, negligence, or accident, or (e) is used notices.
in violation of any other term of this Agreement. Customer agrees
to pay TIBCO for any Support or Services provided by TIBCO Export. Software, including technical data, is subject to U.S.
related to a breach of the foregoing on a time, materials, travel, export control laws, including the U.S. Export Administration Act
lodging and other reasonable expenses basis. If Customer and its associated regulations, and may be subject to export or
obtained the Software from a TIBCO reseller or distributor, the import regulations in other countries. Customer agrees to comply
terms of any warranty shall be as provided by such reseller or strictly with all such regulations and agrees to obtain all
distributor, and TIBCO provides Customer no warranty with necessary licenses to export, re-export, or import Software.
respect to such Software.
Government Use. If the Customer is an agency, department, or
EXCEPT AS SPECIFIED IN THIS LIMITED WARRANTY, THE other entity of the United States Government ("Government"), the
SOFTWARE, SUPPORT AND SERVICES ARE PROVIDED “AS use, duplication, reproduction, release, modification, disclosure or
IS”, ALL EXPRESS OR IMPLIED CONDITIONS, transfer of the Software, or any related documentation of any
REPRESENTATIONS, AND WARRANTIES INCLUDING, kind, including technical data or manuals, is restricted in
WITHOUT LIMITATION, ANY IMPLIED WARRANTY OR accordance with Federal Acquisition Regulation ("FAR") 12.212
CONDITION OF MERCHANTABILITY, FITNESS FOR A for civilian agencies and Defense Federal Acquisition Regulation
PARTICULAR PURPOSE, NONINFRINGEMENT, Supplement ("DFARS") 227.7202 for military agencies. The
SATISFACTORY QUALITY OR ARISING FROM A COURSE OF Software is commercial computer software and commercial
DEALING, USAGE, OR TRADE PRACTICE, ARE HEREBY computer software documentation. Use of the Software and
EXCLUDED TO THE EXTENT ALLOWED BY APPLICABLE related documentation by the Government is further restricted in
LAW. NO WARRANTY IS MADE REGARDING THE RESULTS accordance with the terms of this Agreement, and any
OF ANY SOFTWARE, SUPPORT OR SERVICES OR THAT THE modification thereto.
SOFTWARE WILL OPERATE WITHOUT ERRORS, PROBLEMS
OR INTERRUPTIONS, OR THAT ERRORS OR BUGS IN THE Interoperability. To the extent required by law, at Customer’s
SOFTWARE WILL BE CORRECTED, OR THAT THE request, TIBCO shall provide Customer with the interface
SOFTWARE’S FUNCTIONALITY OR SERVICES WILL MEET information needed to achieve interoperability between the
CUSTOMER’S REQUIREMENTS. NO TIBCO DEALER, Software and another independently created program, on
DISTRIBUTOR, AGENT OR EMPLOYEE IS AUTHORIZED TO payment of TIBCO's applicable fee. Customer agrees to observe
MAKE ANY MODIFICATIONS, EXTENSIONS OR ADDITIONS strict obligations of confidentiality with respect to such
TO THIS WARRANTY. information.
Acceptance; Integration. An Ordering Document shall be development purposes only; “Enterprise” means an unlimited
deemed accepted only by issuance of a TIBCO invoice and solely number of Permitted Instances for a period of three years from
for purposes of administrative convenience. None of the terms of the Purchase Date (unless otherwise set forth in the Ordering
the Ordering Document (other than the Software product name, Document), at which time existing licenses convert to perpetual
number of Permitted Instances, level of Support, description of and Customer may not thereafter deploy additional Permitted
Services, and fees due in connection therewith), shall apply for Instances, and in any event, shall (during the three-year unlimited
any reason or purpose whatsoever, regardless of any statement deployment period) exclude any entity which acquires, is acquired
on any Ordering Document to the contrary, unless countersigned by, merged into, or otherwise combined with Customer if, upon
by TIBCO. This Agreement constitutes the entire agreement such combination, the combined annual revenues or head count
between the parties with respect to the use of the Software, is greater by ten percent (10%) than exists as of the Purchase
Support and Services, and supersedes all proposals, oral or Date (and Customer hereby agree to provide TIBCO with notice
written, and all other representations, statements, negotiations of the number of Permitted Instances deployed at the end of such
and undertakings relating to the subject matter hereof. All future three-year period within thirty days thereafter); “Fab” means
orders of Software, Support or Services by Customer from TIBCO unlimited use for shop-floor manufacturing applications at a Site;
shall be deemed to occur under the terms of this Agreement (with “Workstation” shall mean a single end-user computer that is
or without reference to this Agreement), unless expressly generally intended to be accessed by one person at a time;
superseded by a signed written Agreement between the parties. “Ordering Document” means any purchase order or similar
document or agreement requesting Software, Support or
Term and Termination. Customer may terminate this Agreement Services; “Permitted Instance(s)” means the number of copies of
at any time by destroying all copies of the Software. This Software running on a Server Instance, Workstation, User, or
Agreement will terminate immediately without notice from TIBCO Development basis, on a designated Platform, as set forth in an
if Customer fails to comply with any of its provisions if not cured Ordering Document, including, without limitation, Enterprise, Site
within fifteen days of such failure, or and, upon such termination, and Fab licensing; “Platform” means the operating system set
Customer must cease using and return or destroy all copies of the forth in an Ordering Document; “Purchase Date” means the date
Software. Customer’s obligation to pay accrued charges and fees of the Ordering Document; “Server Instance” means a computer
as well as the sections entitled “Confidentiality”, “Limited performing common services for multiple Desktop machines;
Warranty” and “Limitation of Liability” shall survive any such “Site” means an unlimited number of Permitted Instances at a
termination. specific physical address set forth in the Ordering Document (or,
in the absence of any address, at Customer’s corporate
Authority. You hereby represent and warrant that you have full headquarters); “Software” means the software products listed in
power and authority to accept the terms of this Agreement on an Ordering Document (except as provided in the second
behalf of Customer, and that Customer agrees to be bound by paragraph hereof), in whole and in part, along with their
this Agreement. associated documentation; “TIBCO” means TIBCO Software Inc.;
and “User” means the number of named users with access to the
General. Fees on the Ordering Document (all to be paid on the Software.
latter of thirty days from Invoice by TIBCO or the date set forth in
the Ordering Document) do not include sales, use, withholding, Copyright © 1994-2000 TIBCO Software Inc. ALL RIGHTS
value-added or similar taxes, and Customer agrees to pay the RESERVED.
same, excluding therefrom taxes related to TIBCO’s income and
corporate franchise tax. Customer agree to pay all reasonable Addenda:
costs incurred (including reasonable attorneys’ fees) in collecting None
past due amounts under this Agreement. No delay in the
performance of any obligation by either party, excepting all
obligations to make payment, shall constitute a breach of this
Agreement to the extent caused by force majeure. Customer
hereby grants TIBCO and its independent auditors the right to
audit Customer’s compliance with this Agreement. If any portion
of this Agreement is found to be void or unenforceable, the
remaining provisions shall remain in full force and effect. This
Agreement shall be governed by and construed in accordance
with the laws of the State of California, United States of America,
as if performed wholly within the state and without giving effect to
the principles of conflict of law. The state and/or federal courts in
San Francisco, California, shall have exclusive jurisdiction of any
action arising out of or relating to this Agreement. The United
Nations Convention on Contracts for the International Sale of
Goods is excluded from application hereto. If any portion hereof is
found to be void or unenforceable, the remaining provisions of this
Agreement shall remain in full force and effect.
THIS SOFTWARE PROVIDED BY THE APACHE "Licensed Patents " mean patent claims licensable by a
SOFTWARE FOUNDATION IS PROVIDED "AS IS" AND Contributor which are necessarily infringed by the use or sale
ANY EXPRESS OR IMPLIED WARRANTIES, of its Contribution alone or when combined with the Program.
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS "Original Program" means the original version of the software
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN accompanying this Agreement as released by IBM, including
NO EVENT SHALL THE APACHE SOFTWARE source code, object code and documentation, if any.
FOUNDATION OR ITS CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, "Program" means the Original Program and Contributions.
EXEMPLARY, OR CONSEQUENTIAL DAMAGES "Recipient" means anyone who receives the Program under
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT this Agreement, including all Contributors.
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS 2. GRANT OF RIGHTS
INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, a) Subject to the terms of this Agreement, each Contributor
STRICT LIABILITY, OR TORT (INCLUDING hereby grants Recipient a non-exclusive, worldwide,
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY royalty-free copyright license to reproduce, prepare derivative
OUT OF THE USE OF THIS SOFTWARE, EVEN IF works of, publicly display, publicly perform, distribute and
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” sublicense the Contribution of such Contributor, if any, and
such derivative works, in source code and object code form.
When the Program is made available in source code form: a) it 6. DISCLAIMER OF LIABILITY
must be made available under this Agreement; and b) a copy of
this Agreement must be included with each copy of the Program. EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT,
NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL
Each Contributor must include the following in a conspicuous HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
location in the Program: Copyright © {date here}, International INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Business Machines Corporation and others. All Rights Reserved. DAMAGES (INCLUDING WITHOUT LIMITATION LOST
In addition, each Contributor must identify itself as the originator PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
of its Contribution, if any, in a manner that reasonably allows LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
subsequent Recipients to identify the originator of the TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
Contribution. IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE
PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
4. COMMERCIAL DISTRIBUTION HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
Commercial distributors of software may accept certain
responsibilities with respect to end users, business partners and 7. GENERAL
the like. While this license is intended to facilitate the commercial
use of the Program, the Contributor who include the Program in a If any provision of this Agreement is invalid or unenforceable
commercial product offering should do so in a manner which does under applicable law, it shall not affect the validity or enforceability
not create potential liability for other Contributors. Therefore, if a of the remainder of the terms of this Agreement, and without
Contributor includes the Program in a commercial product further action by the parties hereto, such provision shall be
offering, such Contributor ("Commercial Contributor") hereby reformed to the minimum extent necessary to make such
agrees to defend and indemnify every other Contributor provision valid and enforceable.
("Indemnified Contributor") against any losses, damages and
costs (collectively "Losses") arising from claims, lawsuits and If Recipient institutes patent litigation against a Contributor with
other legal actions brought by a third party against the respect to a patent applicable to software (including a cross-claim
Indemnified Contributor to the extent caused by the acts or or counterclaim in a lawsuit), then any patent licenses granted by
omissions of such Commercial Contributor in connection with its that Contributor to such Recipient under this Agreement shall
distribution of the Program in a commercial product offering. The terminate as of the date such litigation is filed. In addition, If
obligations in this section do not apply to any claims or Losses Recipient institutes patent litigation against any entity (including a
relating to any actual or alleged intellectual property infringement. cross-claim or counterclaim in a lawsuit) alleging that the Program
In order to qualify, an Indemnified Contributor must: a) promptly itself (excluding combinations of the Program with other software
notify the Commercial Contributor in writing of such claim, and b) or hardware) infringes such Recipient's patent(s), then such
allow the Commercial Contributor to control, and cooperate with Recipient's rights granted under Section 2(b) shall terminate as of
the Commercial Contributor in, the defense and any related the date such litigation is filed.
settlement negotiations. The Indemnified Contributor may
All Recipient's rights under this Agreement shall terminate if it
fails to comply with any of the material terms or conditions of this
Agreement and does not cure such failure in a reasonable period
of time after becoming aware of such noncompliance. If all
Recipient's rights under this Agreement terminate, Recipient
agrees to cease use and distribution of the Program as soon as
reasonably practicable. However, Recipient's obligations under
this Agreement and any licenses granted by Recipient relating to
the Program shall continue and survive.
Microstar Software.
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Conventions Used in this Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiv
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvi
Related Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviii
How to Contact TIBCO Customer Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Chapter 1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Request/Reply. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Building Service Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Load Balancing and Fault Tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
How URLs Are Constructed by an HTTP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Request to a Service in an RVDQ Service Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Request to a Service in TAW Service Registry Pool. . . . . . . . . . . . . . . . . . . . . . . . . . 7
Setting Service Instance Defaults. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Chapter 2 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Before Installing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Supported Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Supported Web Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Required Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Optional Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
TIB/Rendezvous API Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Installing on Windows NT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
To Install on Windows NT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Installing on Unix Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Uninstalling on Unix Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Chapter 3 Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Before Starting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Configuring IIS with JRun 2.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Service Pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
C++ Example Service Instances for TIB/Rendezvous 6.x . . . . . . . . . . . . . . . . . . . . 67
TAWrvService . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
TAWrvService::TAWrvService() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
TAWrvService::~TAWrvService() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
TAWrvService::disableRequests() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
TAWrvService::enableRequests() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
TAWrvService::fence() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
TAWrvService::get...() Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
getDirectRequestSubject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
getDispatchQueue() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
getErrorMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
getRequestSubject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
getTibrvCmQueueTransport() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
getTibrvTransport() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
TAWrvService::isEnabled() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
TAWrvService::isValid() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
TAWrvService::onDirectMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
TAWrvService::onMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
TAWrvService::setDirectRequestSubject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
TAWrvService::setRequestSubject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
TAWrvRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
TAWrvRequest::TAWrvRequest() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
TAWrvRequest::get...() Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
getHttpHeader(name) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
getHttpHeaders() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
getHttpMethod() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getHttpUri() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getHttpVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getProtocolVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getUrlParameter(name) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getUrlParameters() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getUrlPath() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getUrlResource() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
getHttpReplyHeader(name) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
getHttpReplyHeaders() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
getHttpReplyOpaqueEntityBody(rLen) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
getHttpReplyReasonPhrase() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
getHttpReplyStatusCode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
getHttpReplyStringEntityBody(rLen) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
getReplyMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
getReplyProtocolVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
TAWrvRequest::isValid() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
TAWrvRequest::reply() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
TAWrvRequest::set...() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
setHttpReplyHeader(name value) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
setHttpReplyOpaqueEntityBody(body, bodyLen) . . . . . . . . . . . . . . . . . . . . . 90
setHttpReplyReasonPhrase(phrase) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
setHttpReplyStatus(code, phrase) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
setHttpReplyStatusCode(code) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
setHttpReplyStringEntityBody(body) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
APSvc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
APSvc::APSvc(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
APSvc::appendToHeartbeat() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
APSvc::disable() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
APSvc::enable(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
APSvc::init(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
APSvc::onMsg(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
APSvc::onTimer() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
APSvc::sendHeartbeat() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
APSvc::start() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
APSvc::startHeartbeating() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
APSvc::terminate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Compiling the Service Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Simple Service C++ Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Starting the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
simplesvc.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
File Service C++ Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Starting the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
filesvc.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
WorldHello Service C++ Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Starting the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
TAWrvService.onMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
TAWrvService.onDirectMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
TAWrvService.setRequestSubject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
TAWrvService.setDirectRequestSubject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
TAWrvService.enableRequests() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
TAWrvService.disableRequests() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
TAWrvService.isEnabled() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
com.tibco.portal.gw.web.api.rv6.TAWrvRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
TAWrvRequest() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
TAWrvRequest.get...() Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
getHttpHeader(name) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
getHttpHeaders() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getHttpMethod() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getHttpUri() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getHttpVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getProtocolVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getUrlParameter(name) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getUrlParameters() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getUrlPath() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
getUrlResource() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
getHttpReplyEntityBody() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
getHttpReplyHeader(name) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
getHttpReplyHeaders() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
getHttpReplyReasonPhrase() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
getHttpReplyStatusCode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
getReplyMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
getReplyProtocolVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
TAWrvRequest.reply...() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
reply() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
reply(entityBody) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
reply(entityBody, statusCode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
reply(entityBody, statusCode, reasonPhrase) . . . . . . . . . . . . . . . . . . . . . . . 154
reply(entityBody) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
reply(entityBody, statusCode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
reply( entityBody, statusCode, reasonPhrase) . . . . . . . . . . . . . . . . . . . . . . 154
TAWrvRequest.set...() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
setHttpReplyEntityBody(body) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
setHttpReplyHeader(name value) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
setHttpReplyReasonPhrase( phrase) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
setHttpReplyStatus(code, phrase) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
setHttpReplyStatusCode(code) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
com.tibco.portal.gw.web.api.rv6.TAWrvException . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
com.tibco.portal.svcreg.APSvc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
APSvc.appendToHeartbeat() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
APSvc.disable() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
APSvc.enable(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
APSvc.init() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
APSvc.run() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
APSvc.terminate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
com.tibco.portal.svcreg.APSvcImpl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
APSvcImpl.APSvcImpl() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
APSvcImpl.appendToHeartbeat() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
APSvcImpl.disable() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
APSvcImpl.enable() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
APSvcImpl.init() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
APSvcImpl.onMsg() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
APSvcImpl.onTimer() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
APSvcImpl.run() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
APSvcImpl.sendHeartbeat() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
APSvcImpl.startHeartbeating(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
APSvcImpl.terminate() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Compiling the Service Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Simple Service Java Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Starting the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Source Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
SimpleSvc.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
File Service Java Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Starting the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Source Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
FileSvc.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
WorldHello Java Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Starting the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Source Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
WorldHello.java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
HelloGoodbye Java Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Starting the Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
TAWrvRequest::getHttpMethod() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
TAWrvRequest::getHttpUri() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
TAWrvRequest::getHttpVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
TAWrvRequest::getHttpRequestEntityBody() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
TAWrvRequest::getUrlParameter() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
TAWrvRequest::getHttpRequestHeader() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
TAWrvRequest::setHttpReplyEntityBody() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
TAWrvRequest::setHttpReplyHeader() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
bTAWrvRequest::setHttpStatusCode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
TAWrvRequest::getRvdqSenderName() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
TAWrvRequest::getRvdqSequenceNumber() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
TAWrvRequest::reply() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
TAWrvRequest::getProtocolVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
TAWrvRequest::setHttpReasonPhrase() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
TAWrvRequest::isValid() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
TAWrvRequest::getUrlParameters() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
TAWrvRequest::getHttpRequestHeaders() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
C++ Example Service Instances for TIB/Rendevous 5.x . . . . . . . . . . . . . . . . . . . . . . . 243
Compiling the Service Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
simplesvc.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
filesvc.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
worldhello.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
hellogoodbye.cc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
TAWrvService.disableRequests() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
TAWrvService.isEnabled() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
TAWrvService.getRvSession() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
TAWrvService.getRvCmqSession() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
com.tibco.portal.gw.web.api.rv5.TAWrvRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
TAWrvRequest.getReplySubject() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
TAWrvRequest.getUrlPath() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
TAWrvRequest.getUrlResource() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
TAWrvRequest.getHttpMethod() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
TAWrvRequest.getHttpUri() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
TAWrvRequest.getHttpVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
TAWrvRequest.getHttpRequestEntityBody() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
TAWrvRequest.getUrlParameter() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
TAWrvRequest.getUrlParameters() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
TAWrvRequest.getHttpRequestHeader() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
TAWrvRequest.getHttpRequestHeaders() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
TAWrvRequest.setHttpReplyEntityBody() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
TAWrvRequest.setHttpReplyHeader() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
TAWrvRequest.setHttpStatusCode() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
TAWrvRequest.getRvdqSenderName() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
TAWrvRequest.getRvdqSequenceNumber() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
TAWrvRequest.reply() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
TAWrvRequest.getProtocolVersion() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
TAWrvRequest.setHttpReasonPhrase() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Java Example Service Instances for TIB/Rendezvous 5.x. . . . . . . . . . . . . . . . . . . . . . . 298
Compiling the Service Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
SimpleSvc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
FileSvc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
WorldHello . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
HelloGoodbye . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
This manual describes how to install, configure, and administer the TIB/Adapter for Web
servlet. It also describes how to build TIB/Adapter for Web service applications using the
C++ API, the Java API, or the TIB/Rendezvous Facilities protocol.
Topics
Convention Used to
Code examples, List program output, listings of code examples, file names,
file names, etc.
commands, configuration file parameters, and literal
programming elements in running text.
Command line Indicate characters in a command line that you must type
characters you exactly as shown. Also used to emphasize particular strings
type in code examples.
<Replace this text with an Indicate text that should be replaced with an actual value.
actual value> This applies to command line syntax, code samples, and
configuration file parameters.
The notational conventions in the table below are used for describing command syntax.
When used in this context, do not type the brackets listed in the table as part of a
command line.
... Ellipsis Indicate that you can repeat an item any number of
times in the command line.
Glossary
Acronym Meaning
HTTP Server An application, typically a web server, that provides data in response
to HTTP client requests transmitted over an Intranet or the Internet.
Acronym Meaning
URL Uniform Resource Locator, a type of URI that identifies the network
resource by location. URI and URL are often used interchangeably in
the context of HTTP as URLs are the only type of URI that are in
common use.
See RFC1738 (Uniform Resource Locators (URL)).
Related Documents
For comments or problems with this manual or the software it addresses, please contact
TIBCO customer support by e-mail or mail using the following:
E-mail: support@tibco.com
URL: www.tibco.com
Address:
Customer Support
TIBCO Software Inc.
3165 Porter Drive
Palo Alto, CA 94304-1213
TIB/Adapter for Web (TAW) is a bridge that allows HTTP clients to issue requests
through a servlet to TIB/Rendezvous-based service instances. It allows you to build
distributed, fault-tolerant, and load-balanced service instances that can be accessed by
HTTP clients, such as web browsers or peer B2B applications.
This product is particularly useful as a way to extend the reach of existing
TIB/Rendezvous based enterprise systems to the Internet, or as a higher performance,
more scalable alternative to the Common Gateway Interface (CGI), or as a foundation for
HTTP-based B2B systems.
Topics
Components, page 2
Request/Reply, page 3
Building Service Instances, page 4
How URLs Are Constructed by an HTTP Client, page 7
Components
Web server
Web browser or
HTTP
other HTTP client TIB/Adapter for
Web servlet
RvMsg
TIB/Rendezvous
RvMsg
RvMsg
Service Service
Service
Service
application application
application
application
Unique service
TIB/Rendezvous
Distributed Queue
service pool
Request/Reply
The TAW servlet enables a web server to recognize HTTP requests addressed to a
TIB/Rendezvous-based service instance. The servlet translates between HTTP and
TIB/Rendezvous and manages the request during its lifetime. Request/reply semantics
are used as follows:
Standard web browsers, or custom HTTP clients issue HTTP requests to a web server
that has loaded the servlet. The URL identifies the target of the request, either by a
TIB/Rendezvous subject name or service name, depending on the load-balancing
approach taken.
The servlet maps the URL into a TIB/Rendezvous subject name, translates the HTTP
request, including headers, into an TIB/Rendezvous message and publishes the
request.
A service instance that is listening to that subject processes the request and replies to
the servlet using return address information present in the request.
The servlet parses the reply TIB/Rendezvous message and transmits its contents to
the client.
See the TIB/Rendezvous Concepts manual for details about subject names.
You can use the TAW APIs to build service instances or you can implement the simple,
request/reply TAW protocol. The TAW APIs make it easy for you to create pools of
service instances that are scalable and fault tolerant. You can use either TIB/Rendezvous
Distributed Queues (RVDQ), or the TAW service registry (APSvc API) to make your
service instances available for this purpose.
On supported platforms the TAW APIs are the best choice for most programmers. Each
API provides a convenient layer to simplify interaction with TIB/Rendezvous version 5.x
and version 6.x.
Service instances need not use these APIs if they conform to the simple, public service
TAW protocol specification. This is helpful in the event that your service instance must be
written using a language or compiler that TAW does not support when TIB/Rendezvous
does support it. A description of the TAW message protocol requirements is provided in
the appendices of this book.
The details of the TIB/Rendezvous API and protocols are described in the
TIB/Rendezvous documentation set.
Web server
HTTP
TAW SERVLET
Service application
(RVDQ Dispatcher) Service
application
Service
application
Service
application
Service
application
Service
application
TAW service registry. If service instances use the APSvc API (in addition to the TAW
API), the TAW servlet maintains state information in an internal registry about all the
service instances that it can reach. These service instances register themselves during
initialization, through the APSvc API. This registration consists of declaring themselves to
be an instance of some generic "service" that is listening for subjects on a globally unique
subject name (nominally an inbox). Following this registration, the service instance sends
out heartbeats that allows TAW to determine when the service has become available.
As shown next, when a request occurs, TAW determines which instance to contact based
upon the scheduling discipline selected (that is set in TIB/Repository), and
heartbeat-based usage and availability information. The advantage of this approach is
better scalability, as the bottleneck no longer is the service instance, but is instead, the web
server. This bottleneck can be resolved using traditional upstream solutions such as Cisco
Director.
Web server
TAW servlet
HTTP
Registry
A B C D E
Service
Service
application A
application E
Service
Service Service
application B
application C application D
An HTTP client issues requests to service instances by contacting the web server that
contains the TAW servlet.
The web_server_name is that of the web server that has loaded the TAW servlet. The
web server name is nominally given as <machine_name>[:port].
The subject_name is the TIB/Rendezvous subject name on which the service instance
listens for requests to process.
For example, the following URL specifies a request to either a single service instance or a
pool of RVDQ based service instances. The web server and servlet is running on the
machine boomer. The subject name is xyz.
http://boomer/servlet/TAW?subject=xyz
The web_server_name is that of the web server that has loaded the TAW servlet. The
web server name is nominally given as <machine_name>[:port].
The service_name is the service instance to contact to process the request.
For example, the following URL specifies a request to a service instance. The web server
and servlet is running on the machine boomer. The service name is myservice.
http://boomer/servlet/TAW?service=myservice
This chapter provides instructions on installing the TIB/Adapter for Web software and
verifying the success of the installation.
Topics
Before Installing
This section lists supported operating systems, web servers and required software. It also
lists optional software.
Required Software
The following products are required and are available separately from TIBCO Software
Inc.:
TIB/Rendezvous software, version 6.3 or better.
TIB/Rendezvous can be installed before or after installing TIB/Adapter for Web
software. Ensure you have sufficient TIB/Rendezvous daemon and TIB/Rendezvous
Router daemon licenses. Since TIB/Adapter for Web uses TIB/Rendezvous as the
underlying communication layer, you need to request enough licenses for all
networks (e.g., client subnets, server subnets, development subnets, etc.). If you do not
have enough TIB/Rendezvous licenses, please contact your TIBCO Software Inc.
representative.
TIB/Repository 3.2.2 or better.
TIB/Adapter SDK 3.2.0 or better.
TIB/AdapterAdminstrator 3.2.0 or better.
The following product is required if you are using Microsoft Internet Information Server.
The product is available from Allaire (Go to www.Allaire.com for more information.)
JRun 2.3.3 or JRun 3.0 (allows Java servlets to run under IIS web servers).
The following product is required and is typically installed by the TIB/Repository
installation procedure:
Java Runtime Environment (JRE) 1.2.2.
Optional Software
TIB/Hawk software, version 3.0 or better, available separately from TIBCO Software
Inc.
Installing on Windows NT
To Install on Windows NT
You install the software using InstallShield. You need administrator privileges for your
system. Follow these steps to install the software:
1. Insert the installation CDROM or download the software and double-click the
installation icon.
The installation software starts unpacking the software and prompts for an
installation folder location.
2. InstallShield then checks whether the appropriate version of TIB/Rendezvous is
installed. If it is not currently installed on your system, you are advised to install it at a
later time.
3. InstallShield launches and checks for the correct JRE version. If the JRE is not found
under the TIB_JAVA_HOME environment variable, it is created and the JRE is
automatically installed by the installation program.
4. After installation is complete, you are asked whether you would like to view the
README file. Select or deselect the check box, then click Finish.
5. Go to Chapter 3, Administration, on page 15 to configure your web server to use the
servlet.
You can get the software from an FTP site as directed by your TIBCO Sales Representative
or CDROM.
If the software is downloaded from an FTP site, you must unpack the software before
installing it.
If installing the software from a CDROM, change directory to your platform directory
and proceed to step 6.
1. Change directory to the temporary directory to hold the installation file that will be
downloaded from the FTP site. For example:
cd /tmp
2. Go to the FTP site and download the software to the temporary directory.
3. Uncompress the installation file.
uncompress <installation_file>.tar.Z
4. Create another temporary directory and change directory to it:
mkdir /tmp/tawinstalltmp
cd /tmp/tawinstalltmp
5. Uncompress the installation file and execute the tar command against it. (The
installation file must not be in the directory where the files will be unpacked.) For
example:
tar xvf /tmp/<installation_file>.tar
Two installation types may be available, native and tar. If both are available, when the
installation procedure starts, you will be prompted to choose a type.
— Choose native if you have root access and want the software to be recorded in the
system software package database. If you choose native, the installation location
defaults to /opt/tibco/adweb/.
— Choose tar if you do not want to install the software as root. The software will not
be recorded in the system software package database. You will be prompted for an
absolute directory path name where the software is to be installed.
7. Move the HTML files and default directory and its contents found in the
<install_dir>/data directory to your web server’s Primary Document Directory.
Platform Command
To remove a TIB/Adapter for Web software tar installation, change to your installation
directory and use the delete command for your Unix operating system.
Topics
Before Starting
Before starting, make sure that your web server is installed correctly by starting the web
publishing service. If your web server is installed in the default location, type the
following in your web browser:
http://<host_name>/
otherwise, type:
http://<host_name>:<port number>/
Your web server’s default home page should display in your web browser.
You must ensure that JRun is operational and configured correctly using the installation
verification tools supplied by Allaire. Type the following in your Address field in Internet
Explorer to test the JRun installation:
http://<web_server_name>/servlet/Counter
If the URL displays correctly proceed with the instructions found in this section. If the
URL does not display correctly consult your JRun documentation for instructions on how
to proceed.
3. In the Java Classpath (java.exe only) field, type the location of the .jar files
(separated by a semicolon) as shown next (for Windows NT). Note that drive c is used
in the example. You should use the drive name on which the software is installed, if it
is different.
— c:/tibco/Repository/jars/TIBRepoClient32.jar;
— c:/tibco/Adapter/SDK/java/Maverick32.jar;
— c:/tibco/tibrv/lib/tibrvj.jar;
— c:/tibco/adweb/java/taweb.jar;
4. Click Save, then click Services. A dialog box similar to the following displays. Under
Service ID, click the jse service and click Service Config.
5. In the jse (Service Config) dialog box, click Aliases. Click Add to add a new alias
setting. The dialog box should be similar to the following screen.
6. Information must be added in the Name, Class Name and Init Arguments fields:
a. In Name, type TAW
b. In Class Name, type com.tibco.portal.gw.web.TAW
c. Double-click in the Init Arguments field. The following dialog box appears. Click
Add to add a line for the entry. In Name, type configFile. In Value, type the
location of the TIB/Repository file. Set the TAW debug subject and debug level
7. Click the Pre-Load box so a check mark displays. The dialog box should look similar
to the following:
8. Click Save, then click Close. In the next dialog box, click Close to end your session
with the JRun Service Manager.
9. Reboot your system.
10. Go to Verifying Installation and Configuration on page 36 to ensure the configuration
and installation is correct.
You must ensure that JRun is operational and configured correctly using the installation
verification tools supplied by Allaire. Type the following in your Address field in Internet
Explorer to test the JRun installation:
http://<web_server_name>/demo
If the URL displays correctly, click the example servlets and test. If the URL does not
display correctly consult your JRun documentation for instructions on how to proceed.
Before sending a request to the TAW servlet, you must configure JRun with the location of
the TAW .jar files and .dat (repository) file. Both tasks are done in the JRun Service
Manager.
5. In the Java Classpath field, type the location of the .jar files as shown next (for
Windows NT). Note that drive c is used in the example. You should use the drive
name on which the software is installed, if it is different.
— c:/tibco/Repository/jars/TIBRepoClient32.jar
— c:/tibco/Adapter/SDK/java/Maverick32.jar
— c:/tibco/tibrv/lib/tibrvj.jar
— c:/tibco/adweb/java/taweb.jar
6. In the left frame under JRun Default Server, expand Web Applications.
You can create a new application or use the Default User Application.
8. In the left frame, under Default User Application, click Servlet Definitions.
12. Set the preload option for TAW by clicking set preload order.
If using an iPlanet web server, before sending a request to the servlet, you must configure
it with the location of the TAW .jar files and .dat (repository) file. Both tasks are done in
the Netscape Enterprise Administration Server Service Manager.
2. The following screen appears. The server can be on or off. Click the Servlets tab to
continue.
3. The following screen appears. The Activate the Servlet Engine? option must be
selected as shown. In the navigation bar at right, click Configure JVM Attributes.
In the Classpath: field, type the location of the .jar files separated by a colon as
shown in the previous diagram. For example:
— /tibco/Repository/jars/TIBRepoClient32.jar;
— /tibco/Adapter/SDK/java/Maverick32.jar;
— /tibco/tibrv/lib/tibrvj.jar;
— /tibco/adweb/java/taweb.jar;
5. In the navigation bar at right, click Configure Servlet Attributes. The following
screen appears:
d. Set the repository file, TAW debug subject and debug level (note that there is no
space after the comma). In Servlet Args:
configFile=<install_dir>/data/taw5config.dat,
debugSubject=taw.debug.iplanet,debugLevel=0
You may want to change the arguments depending on your needs. See
setDebugLevel() on page 62 for more information about setting the debug level. See
setDebugSubject() on page 64 for more information about setting the debug subject.
You can verify the installation and configuration by running the simple service instance.
The service returns a string value to an HTTP client when the service is called by the
client.
The following set up is used:
One command window where the service is run.
A web browser to send the request.
Start the simple service and send a request.
1. In a command window change directory to the TAW samples directory:
cd <installation_path>/samples/rv6/java
2. Edit the Makefile under the directory to reflect your current environment, then type
make or nmake (Microsoft utility).
3. Make sure that tibrvj.jar and taweb.jar are in CLASSPATH. Type the following to
start the simple service instance:
> java SimpleSvc taw.simple "Hello" and press Enter
The simple service starts and is ready to process requests. The service listens on the
taw.simple subject and returns the string "Hello" to each HTTP client that sends a
request on the taw subject.
4. In a web browser, type the following in the Location field (Netscape) or Address field
(Internet Explorer):
http://<web_server_name>/servlet/TAW?subject=taw.simple and press Enter
The servlet sends a discovery message along with its inbox on TIB/Rendezvous. The
service receives the request, processes it and returns the results to the servlet, which
returns it to the HTTP client. For example:
GUI or non GUI based HTTP clients can interact with the TAW servlet. Depending on
your client, the next sections explain how to configure the TAW servlet to provide a
different set of defaults for any or all of your service instances.
Figure 4 TIB/AdapterAdminstrator
You can add entries for service instances under the ServiceConfigurationData section
and configure them as needed with a response timeout and HTML files for displaying
errors. The previous diagram shows entries for two service instances, one named default
and another named foo. The entries defined for default will be used by each service
instance, unless it has a named entry. For example, the foo service instance uses its entry
rather than that defined for default.
Note: If you do not add entries to the The ServiceConfigurationData section for your
service instances, they will use the values defined in default.
The next table lists the entries that can be defined. The last three entries take a path to an
HTML file. The HTML file must be made available under the web server’s home page in a
directory that has the same name as the service instance defined in the
ServiceConfigurationData section. For example (using IIS), the service instance foo
has the directory named inetpub\wwwroot\foo.
Name Value
timeout The amount of time in seconds that can expire after which the
servlet no longer waits for a response.
serviceNotUPURL Path to the HTML page that displays if the service is not up.
2. Display the editor for the adapter instance and click the Custom tab.
3. Right-click on ServiceConfigurationData and choose New Association
Attribute. Type service instance name. A directory that uses the service name must
exist under your web servers home page directory.
4. Right-click on the service name icon and choose New String Attribute. Type
timeout and assign a value for the timeout. The value is given in seconds.
5. Right-click on the service name icon and choose New String Attribute. Type
timeoutURL and assign a value. The value is should be the path to an HTML file that
will display if the timeout is exceeded before the service responds.
6. Right-click on the service name icon and choose New String Attribute. Type
serviceNotUPURL and assign a value. The value is should be the path to an HTML file
that will display if the service is not up.
7. Right-click on the service name icon and choose New String Attribute. Type
internalError and assign a value. The value is should be the path to an HTML file
that will display if an internal error within the service instance occurs.
8. Create and place the HTML files identified in the ServiceConfigurationData
section, under the home directory for the web server in a directory that is named with
the service instance name given in step 3.
Parameter Description
Parameter Description
modifiedMessage 1—The backend service instance can query for client host
and client address. If any other value is given, the
information is not provided.
You can configure TAW to send messages on a non default TIB/Rendezvous service or
daemon by using TIB/AdapterAdminstrator to change the MainRvSession parameters.
See the TIB/AdapterAdministrator User’s Guide for information about performing the
following steps. The guide explains how to invoke TIB/AdapterAdministrator, find the
repository to load, and explains the TIB/Rendezvous session parameters.
1. Start TIB/AdapterAdministrator and logon to the repository that contains
configuration information for the servlet. The repository path name is
<taw_install_directory>/data/taw5config.dat.
After this, but in the beginning of the file, anywhere in the block containing Init
definitions, place the Init for the nametrans plugin. This directive has parameters
that specify:
— servletURL. The complete URL, including scheme, of the servlet.
— mapN. A string containing the shexp pattern to match, followed by the TAW query
string, which at a minimum will specify the subject on which TAW should issue the
request.
For example:
This directive routes all requests whose URLs match /foo/bar/* to TAW requests on
the subject foo.bar. URLs matching /foo/baz/my* will use the subject foobar.
Before any other NameTrans directives in the default object section (that starts with
<Object name="default">), type:
NameTrans fn="tawNmTrns"
TIB/Adapter for Web contains TIB/Hawk AMI methods that can be used to change and
display certain parameters at run-time. TIB/Hawk, an enterprise monitoring tool from
TIBCO Software Inc., monitors and manages distributed applications and systems.
Topics
Introduction, page 46
Starting TIB/Hawk Software, page 47
The Auto-Discovery Process, page 48
Invoking Microagent Methods, page 49
Available Microagents, page 52
Introduction
The following sections describe how to start TIB/Hawk product components on Unix and
Windows NT platforms.
2. In a new command window, set the DISPLAY environment variable for your
workstation by typing:
setenv DISPLAY <hostname>:0.0
After TIB/Hawk Display is started, the operation is the same on the Unix and Windows
NT platforms.
This dialog has two modes, Invoke and Subscribe. Invoking a method immediately
returns a single set of current results. Subscribing provides updates of current results
at regular intervals. Radio buttons at the bottom of the dialog control these modes.
3. Click a microagent name, such as Self, to display a list of associated methods and text
descriptions in the panels below.
4. Click the name of the method to invoke, such as getComponentInfo.
If the method accepts arguments, fields for each argument display in the upper right
panel. Detailed help text displays in the lower panel.
5. Specify any arguments for the method invocation.
6. Verify that the Invoke radio button is selected.
7. Click the Invoke button to invoke the selected method.
The Invocation Results dialog displays the results returned by the method.
Available Microagents
Each TIB/Adapter for Web instance is represented by two TIB/Hawk microagents. One
microagent represents the adapter itself. One microagent is provided by the TIB/Adapter
for SDK product, which is used to develop TAW.
TAW5agent:<agent_id>. Monitors the adapter itself.
COM.TIBCO.ADAPTER:<agent_id>. Monitors the adapter main thread.
TAW5agent:<agent_id> Methods
The following table lists each method available for the TAW5agent:<agent_id> microagent
and page on which the method is explained.
COM.TIBCO.ADAPTER.TAW:<agent_id> Methods
The following table lists each method available for the
COM.TIBCO.ADAPTER.TAW:<agent_id> microagent and page on which the method is
explained. Although the Microagents, Methods and Arguments dialog in TIB/Hawk
Display lists more methods for this microagent than are documented here, only the
following methods are supported.
getConfig()
COM.TIBCO.ADAPTER.TAW:<agent_id>
Purpose
Retrieves generic configuration information. More specific configuration information is
accessed through separate methods.
Parameters
None
Returns
getConfigProperties()
COM.TIBCO.ADAPTER.TAW:<agent_id>
Purpose
Returns all attributes and elements for the given repository object.
Parameters
Property string Name of the property for which elements (tags) and
attributes are desired. For example, agentone/startup.
If no value is given, all properties are returned.
Returns
getDebugLevel()
Taw5agent:<agent_id>
Purpose
Returns the current debug level setting.
Parameters
None
Returns
getDebugSubject()
Taw5agent:<agent_id>
Purpose
Returns the debug subject name.
Parameters
None
getServletContext()
Taw5agent:<agent_id>
Purpose
Returns context information for the servlet.
Parameters
None
Returns
Servlet Context String Returns the servlet major and minor release number and
release information about the web server on which the
servlet is installed.
getStatus()
COM.TIBCO.ADAPTER.TAW:<agent_id>
Purpose
Retrieves basic status information about the adapter.
Parameters
None
Returns
New Errors integer Number of errors since the last call to this method.
getVersion()
COM.TIBCO.ADAPTER.TAW:<agent_id>
Purpose
Retrieves version information for the current application. Two lines may be returned, one
for the TIB/Adapter SDK, one for the adapter.
Parameters
None
Returns
Name Description
_onUnsolictedMsg()
TAW5agent:<agent_id>
COM.TIBCO.ADAPTER.TAW:<agent_id>
Purpose
Displays all alert messages sent from TAW.
Parameters
None
Returns
This method returns all alert messages if they exist or an error if not successful.
setDebugLevel()
COM.TIBCO.ADAPTER.TAW:<agent_id>
Purpose
Set the debug level for the current service instance.
Remarks
This information is useful as an aid in the debugging process. When the debug level is set
to 2, debug information is written to a TIB/Rendezvous message and published on the
debug subject. You can invoke tibrvlisten on the debug subject to display the message.
This allows you to be sure the backend process is getting the right information and
reporting the correct information back. The debug message includes the inbound message
from the HTTP client (or web browser), outbound message to the backend service and
response from the backend service. For example:
Inbound message from HTTP client
[2000-09-27 12:45:46]: subject=taw5.debug, message={Thread-Id :
="Thread[Thread-11,5,main]" Start Time : =2000-09-27 19:47:22.675000000Z
Request Headers : ={connection="Keep-Alive" user-agent="Mozilla/4.6 [en]
(WinNT; U)" pragma="no-cache" host="vipin-l" accept="image/gif,
image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*"
accept-encoding="gzip" accept-language="en,pdf"
accept-charset="iso-8859-1,*,utf-8"} Request Parameters :
={subject="taw5listen"}
Parameter
Returns
Returns OK if successful or an error if not successful.
setDebugSubject()
Taw5agent:<agent_id>
Purpose
Sets the debug subject on which configuration information will be published.
Parameters
Returns
Returns OK if successful or an error if not successful.
This chapter describes the C++ API used with TIB/Rendezvous 6.x. Use this API to write
TIB/Adapter for Web service instances when linking to TIB/Rendezvous 6.x. With this
API you can also create a service pool and use TIB/Rendezvous distributed queues or the
TAW service registry to load-balance requests to service pool members.
This chapter also includes sample source programs that illustrate how to write both
simple service instances as well as more complex RVDQ-based services.
Topics
Overview, page 66
TAWrvService, page 68
TAWrvRequest, page 83
APSvc, page 92
Compiling the Service Examples, page 104
Simple Service C++ Example, page 105
File Service C++ Example, page 108
WorldHello Service C++ Example, page 112
HelloGoodbye Service C++ Example, page 116
MultiDispatcher Service C++ Example, page 121
Simple Service Registry C++ Example, page 125
Overview
Use this API to write TAW service and service-pool applications. It provides the
capability to easily use TIB/Rendezvous version 6.x distributed queues or the TAW
service registry to load-balance requests to service pool members.
The TIB/Adapter for Web distribution contains sample source programs that illustrate
how to write very simple applications as well as more complex RVDQ-based services.
The Basics
Your TIB/Adapter for Web service instances must perform the following basic steps:
1. Include rv6/TAWrv.h
2. Create a subclass of TAWrvService that implements TAWrvService::onMsg(). Inside
onMsg(), arrange for one of the TAWrvRequest::reply() methods to return data to
the servlet.
3. Instantiate your TAWrvService subclass in your main program, and then call its
enableRequests() method to begin listening for requests.
The example programs, simplesvc.cc and filesvc.cc illustrate this basic structure.
They also show how to handle non-text data and manipulate HTTP reply headers.
Service Pools
In some applications, the request rate can exceed the capacity of a single service instance.
A service pool is a fault-tolerant and load-balanced collection of services.
TIB/Rendezvous Distributed Queues (RVDQ) ensure that a request is delivered to only
one pool member. The service registry API can also be used for load balancing. See
Building Service Instances on page 4 for an overview of both methods.
The TAW C++ API makes it very convenient to set up service pools. For more information
on setting up service pools, see Setting up RVDQ Service Pools on page 316.
Classes
There are only two classes that you need to know about to use the C++ API:
TAWrvService
TAWrvRequest
You must create your own subclass of TAWrvService. The onMsg() or onDirectMsg()
methods of this subclass will receive TAWrvRequest objects which contain all of the HTTP
information about the request as well as any data.
Use the following class to call the service registry API:
APSvc
TAWrvService
RV 6.x only
Class
Purpose
TAWrvService is an abstract class. Your application needs to create a subclass of
TAWrvService that implements the request callbacks that will be invoked when requests
are received.
Remarks
There are two constructors. The first constructor is used to build standard,
non-load-balancing service instances, using a TibrvTransport. The second constructor is
used to build load-balancing service instances based on TIB/Rendezvous distributed
queues, using a TibrvCmQueueTransportQueue. If directSubject is specified, requests
may be sent directly to this service instance using that subject, bypassing the RVDQ
scheduler.
Member Summary
TAWrvService::TAWrvService() Constructor 70
TAWrvService::~TAWrvService() Destructor 72
TAWrvService::TAWrvService()
RV 6.x only
Constructor
Declaration
TAWrvService(TibrvTransport* pRvTransport,
TibrvQueue* pQueue = 0,
const char* requestSubject=0,
const char* directRequestSubject=0);
TAWrvService(TibrvCmQueueTransport* pRvCmqTransport,
TibrvQueue* pQueue = 0,
const char* requestSubject=0,
const char* directRequestSubject=0);
Purpose
All applications must provide a subclass of TAWrvService that implements the onMsg
method. The first constructor is used to setup normal reliable communications between
the servlet and your application. The second constructor is used to build RVDQ-based
service pools.
Remarks
Subjects need not be specified here, but must be set prior to enabling the service.
Parameters
Name Description
Name Description
Example
class SimpleService : public TAWrvService
{
public:
SimpleService(TibrvTransport *pRvTransport, TibrvQueue *pQueue,
const char* requestSubject, const char* replyString)
: TAWrvService(pRvTransport, pQueue, requestSubject),
_replyString(replyString){};
~SimpleService(){};
void onMsg(TAWrvRequest* pRequest);
private:
const char* _replyString;
};
Errors
Use the isValid() member to make sure that the constructor did not fail. For a
descriptive error message string, use the getErrorMsg() member.
See Also
TAWrvService::isValid(), page 78.
getErrorMsg(), page 76.
TAWrvService::~TAWrvService()
RV 6.x only
Destructor
Declaration
~TAWrvService();
Purpose
This method destroys the TAWrvService instance from which it is called and releases all
resources.
Remarks
This destructor must be called whenever you are finished with communications between
the servlet and your application.
TAWrvService::disableRequests()
RV 6.x only
Method
Declaration
virtual tibrv_bool disableRequests();
Purpose
Stop listening for requests.
Remarks
This method destroys the TibrvListener objects created in enableRequests().
Parameters
Returns TIBRV_TRUE if successful, TIBRV_FALSE otherwise.
TAWrvService::enableRequests()
RV 6.x only
Method
Declaration
virtual tibrv_bool enableRequests();
Purpose
Start listening for requests.
Remarks
Prior to invoking enableRequests(), you must set the subjects on which your service
will accept requests. You can do this in the constructor, or use the setRequestSubject()
and setDirectRequestSubject(). This method creates the TibrvListener objects
that remain valid until the disableRequests() method is invoked.
Parameters
Returns TIBRV_TRUE if successful, TIBRV_FALSE otherwise.
See Also
TAWrvService::setRequestSubject(), page 82.
TAWrvService::setDirectRequestSubject(), page 81.
TAWrvService::disableRequests(), page 73.
TAWrvService::fence()
RV 6.x only
Method
Declaration
virtual void fence();
Purpose
The fence() method is used to block the program.
If the method is not used, the main program will exit, preventing the dispatcher thread
from doing its job (a dispatcher thread is created to listen on the request subject). You
might want to override the method to block the main application and allow its thread to
service, while exit and do clean up under a special condition.
TAWrvService::get...() Accessors
RV 6.x only
Method
Declaration
virtual const char* getDirectRequestSubject();
TibrvQueue* getDispatchQueue();
virtual const char* getErrorMsg();
virtual const char* getRequestSubject();
const TibrvCmQueueTransport* getTibrvCmQueueTransport();
const TibrvTransport* getTibrvTransport();
Purpose
Accessor methods for TAWrvService instances.
Name Description
TAWrvService::isEnabled()
RV 6.x only
Method
Declaration
virtual tibrv_bool isEnabled();
Purpose
Determine whether the service is currently listening for requests.
Parameters
Returns TIBRV_TRUE if the service is currently listening for requests, TIBRV_FALSE
otherwise.
TAWrvService::isValid()
RV 6.x only
Method
Declaration
virtual tibrv_bool isValid();
Purpose
Provide a way for the TAWrvService constructor to report that it failed.
Remarks
Use the getErrorMsg() to determine the reason for the failure.
Parameters
Returns TIBRV_TRUE if the object could be correctly built, TIBRV_FALSE otherwise.
See Also
getErrorMsg(), page 76.
TAWrvService::onDirectMsg()
RV 6.x only
Method
Declaration
virtual void onDirectMsg(TAWrvRequest* pRvRequest);
Purpose
This method is only relevant to RVDQ-based service instances. This method is called
when a request is received on the direct request subject. Requests to direct request
subjects are not intercepted by the RVDQ scheduler. The default implementation merely
invokes the onMsg() method.
Parameters
Name Description
TAWrvService::onMsg()
RV 6.x only
Method
Declaration
virtual void onMsg(TAWrvRequest* pRvRequest) = 0;
Purpose
All applications must provide a subclass of TAWrvService that implements the onMsg
method. This method is called when a request is received.
Parameters
Name Description
TAWrvService::setDirectRequestSubject()
RV 6.x only
Method
Declaration
virtual void setDirectRequestSubject(const char* subject);
Purpose
Set the subject name used to listen for requests directed at a specific member or members
of an RVDQ-based service pool. RVDQ-based applications can use this subject to get
requests without the intervention of the RVDQ scheduler.
Parameters
Name Description
TAWrvService::setRequestSubject()
RV 6.x only
Method
Declaration
virtual void setRequestSubject(const char* subject);
Purpose
Set the subject name used to listen for requests. This subject is used by both RVDQ-based
pooled services, or by singleton applications.
Parameters
Name Description
TAWrvRequest
RV 6.x only
Class
Purpose
TAWrvRequest objects are manufactured when requests are received. They encapsulate all
of the HTTP information in the request, including the communication endpoint to reply
to. Members can be used to access HTTP request information, as well as to prepare a
reply.
Remarks
These objects are created and destroyed by the API and are valid for the duration of one
invocation of your application’s implementation of TAWrvService::onMsg(). You must
copy any data or header information if your application will need them after onMsg()
returns.
Member Summary
TAWrvRequest::TAWrvRequest() Constructor 84
TAWrvRequest::TAWrvRequest()
RV 6.x only
Constructor
Declarations
TAWrvRequest(TibrvMsg& rRvMsg, TibrvTransport *pRvTransport);
Purpose
Sets up an object that is used to respond to a request.
Parameters
Name Description
TAWrvRequest::get...() Accessors
RV 6.x only
Methods
Declarations
// ----------------- Request ------------------
const char* getHttpHeader(const char* name);
const TibrvMsg& getHttpHeaders();
const char* getHttpMethod();
const char* getHttpUri();
const char* getHttpVersion();
const char* getProtocolVersion();
const char* getUrlParameter(const char* name);
const TibrvMsg& getUrlParameters();
const char* getUrlPath();
const char* getUrlResource();
Purpose
Accessors for TAWrvRequest instances.
getHttpMethod() Returns the HTTP method from the HTTP request line.
Returns: NULL if not found.
getHttpUri() Returns the HTTP URI from the HTTP request line.
Returns: NULL if not found.
getHttpVersion() Returns the HTTP version from the HTTP request line.
Returns: NULL if not found.
getUrlParameters() Returns all query parameters from the URL on the request
line. It returns a TibrvMsg containing one field for each
parameter.
getHttpReplyHeader(name) Returns the object for a given Http Header, given the name
of field to get. The look up is case insensitive.
If multiple values are associated with headers of the server
name, only one value will return. Use
getHttpReplyHeaders() to manually get all the values for
this call.
name—Char*. Name of field to get.
Returns: NULL if not found.
TAWrvRequest::isValid()
RV 6.x only
Method
Declaration
tibrv_bool isValid();
Purpose
Tests object validity. Useful for detecting failures during a TAWrvRequest constructor.
This method is typically not used because TAWrvRequest is constructed internally.
Parameters
None.
Example
TAWrvRequest* pRequest = new TAWrvRequest(msg, pImpl->_pRvTransport);
if(!pRequest->isValid())
{
pImpl->_errorMsg = "Bad request data";
#if DEBUG
printf("TAWrvServiceRequestCallback::onMsg %s\n", pImpl->_errorMsg);
printf("\n");
#endif
}
else
pImpl->_rTAWrvService.onMsg(pRequest);
delete pRequest;
}
TAWrvRequest::reply()
RV 6.x only
Method
Declaration
tibrv_bool reply();
tibrv_bool reply(const void* entityBody,
unsigned int entityBodyLen,
int statusCode = 200,
const char* reasonPhrase = "OK");
Purpose
These methods marshall parameters from the TAWrvRequest into an TibrvMsg and send
them back to the requesting servlet. The first form assumes that all reply headers and data
have been stored using TAWrvRequest set methods. The remaining two forms are for
convenience. The second form is for sending binary data, and the third form is for sending
strings. Make sure you have the correct argument datatypes that match the parameter
datatypes.
Parameters
Name Description
entityBody The desired reply entity body. Either a string or buffer of binary
data, depending on whether entityBodyLen is specified.
TAWrvRequest::set...()
RV 6.x only
Methods
Declarations
void setHttpReplyHeader(const char* name, int value);
void setHttpReplyHeader(const char* name, const char* value);
void setHttpReplyOpaqueEntityBody(const void* body, unsigned int
bodyLen);
void setHttpReplyReasonPhrase(const char* phrase);
void setHttpReplyStatus(int code, const char* phrase);
void setHttpReplyStatusCode(int code);
void setHttpReplyStringEntityBody(const char* body);
Purpose
Sets a value for TAWrvRequest instances.
Name Description
setHttpReplyOpaqueEntityBody Sets string data into the HTTP entity body (i.e. data
(body, bodyLen) payload) of the reply.
body—void*. Binary payload data
bodyLen—The number of bytes in the body.
Name Description
setHttpReplyStringEntityBody Sets binary data into the HTTP entity body (that is,
(body) data payload) of the reply.
body—string. Payload data.
APSvc
RV 6.x only
Class
Purpose
The APSvc class implements the heartbeat protocol interface.
Member Summary
APSvc::APSvc() Constructor 93
~APSvc() Destructor
APSvc::APSvc()
RV 6.x only
Constructor
Declaration
APSvc(const char* serviceName,
const char* requestSubject,
TibrvTransport *pHeartbeatTransport,
const char* heartbeatSubject,
double heartbeatInterval,
double failureTolerance,
const char* registrySubject,
tibrv_i8 readyStatus);
Purpose
Create a service registry instance.
Parameters
Name Description
APSvc::appendToHeartbeat()
RV 6.x only
Method
Declaration
virtual TibrvMsg* appendToHeartbeat();
Purpose
The method is called just before a heartbeat is emitted.
The method returns a TibrvMsg containing auxiliary information. The method allows you
to append any auxiliary information to be associated with this service instance on the
client’s APSvcRegistry by overriding this method. The current implementation just
returns NULL.
APSvc::disable()
RV 6.x only
Declaration
void disable();
Purpose
Inform all APSvcRegistry instances that this service instance is temporarily disabled and
unable to receive requests.
APSvc::enable()
RV 6.x only
Declaration
void enable();
Purpose
Informs all APSvcRegistry instances that this service instance is ready to receive
requests.
APSvc::init()
RV 6.x only
Method
Declaration
void init(const char* serviceName,
const char* requestSubject,
TibrvTransport *pHeartbeatTransport,
const char* heartbeatSubject,
double heartbeatInterval,
double failureTolerance,
const char* registrySubject,
tibrv_i8 readyStatus);
Purpose
Initialize a service registry instance .
Parameters
Name Description
APSvc::onMsg()
RV 6.x only
Declaration
void onMsg(TibrvListener *listener, TibrvMsg& msg);
Purpose
Respond to an announcement message from an APSvcRegistry by sending a heartbeat.
This method is implemented for the abstract class TibrvMsgCallback. It will be called
when there is an incoming message with the request subject. You need not call this
method.
Parameters
Name Description
APSvc::onTimer()
RV 6.x only
Declaration
void onTimer(TibrvTimer *timer);
Purpose
Process timer events.
This method is implemented for the abstract class TibrvTimerCallback. It will be called
when there is a timer event. You need not call this method.
Parameter
Name Description
APSvc::sendHeartbeat()
RV 6.x only
Declaration
void sendHeartbeat();
Purpose
Send a heartbeat, called internally, by responding to an announcement message from an
APSvcRegistry. You can invoke this method to explicitly send a heartbeat.
APSvc::start()
RV 6.x only
Method
Declaration
void start();
Purpose
Starts sending heartbeats on the network so the registry service can recognize that the
service instance is running. This method must be invoked after this class instance is
created.
APSvc::startHeartbeating()
RV 6.x only
Declaration
void startHeartbeating();
Purpose
Starts sending periodic heartbeats by activating a timer. The method is normally called by
APSvc::start() and not typically called directly. This call should be invoked only after a
service instance is disabled and then enabled.
APSvc::terminate()
RV 6.x only
Declaration
void terminate();
Purpose
Informs all APSvcRegistry instances that this service instance has exited.
This example emulates a simple service that given a subject name and string, returns the
string in a web browser that is invoked with the subject name.
The program will return a page containing hello to your web browser and the reply
message that it is sending to the servlet on the command line.
Source Code
The simplesvc.cc file where the simple service is defined is listed next. In the code, the
basic steps are to:
Derive a subclass from TAWrvService that provides an implementation of the abstract
method onMsg().
Define the onMsg() method so it is invoked by TAW whenever a request is received.
This implementation returns the string specified on the command line when the
program was invoked to the client.
Create an instance of SimpleService that uses command line parameters to
determine what subject to accept requests on, and what string to return in response to
a request.
Check that your TAWrvService subclass is valid before proceeding further. The
isValid() method is used for this purpose. If the object is not valid, the reason may
be determined by invoking the getErrorMsg() method.
Start request processing.
simplesvc.cc
#include "rv6/TAWrv.h"
#include "stdlib.h"
#include "string.h"
void
SimpleService::onMsg(TAWrvRequest* pRequest)
{
const char* buf;
pRequest->reply(_replyString);
TibrvStatus status;
if(!simpleService.isValid())
{
printf("TAWrvService constructor failed - %s\n",
simpleService.getErrorMsg());
exit(-1);
}
if(! simpleService.enableRequests() ) {
printf("Unable to enable request processing - %s\n",
simpleService.getErrorMsg());
}
else {
simpleService.fence(); // wait forever...
}
return 0;
}
This example emulates a simple service that shows how to transmit string or binary data
and set HTTP reply headers.
Source Code
The filesvc.cc file where the simple service is defined is given next. In the code, the
basic steps are to:
Derive a subclass from TAWrvService that provides an implementation of the
abstract method onMsg(). The method is invoked by TAW whenever a request is
received. This implementation returns the file specified on the command line and
adds the “content-type” HTTP header value that was also specified on the command
line.
Create an instance of FileService that uses command line parameters to determine
what subject to accept requests on, which file to return, and the HTTP content-type.
Check that your TAWrvService subclass is valid before proceeding further. The
isValid() method is used for this purpose. If the object is not valid, the reason may
be determined by invoking the getErrorMsg() method.
Start request processing.
filesvc.cc
#include "rv6/TAWrv.h"
#include "stdlib.h"
#include "string.h"
if(!fp)
{
printf("Unable to open \"%s\" for reading\n", _filePath);
exit(-1);
}
if (fseek(fp, 0, SEEK_SET) != 0) {
printf ("Unable to seek to front of the file %s\n", _filePath);
exit(-1);
}
_data =(unsigned char*) malloc(bufSize * sizeof(char));
bytesRead = fread(_data, sizeof(char), bufSize, fp);
if (bufSize != bytesRead) {
printf ("size of file %d not equal to bytes readed %d\n", bufSize,
bytesRead);
exit(-1);
}
fclose(fp);
_dataLen = bufSize;
if(isBinaryFile(filePath))
{
_dataRvmsgType = TIBRVMSG_OPAQUE;
}
}
void
FileService::onMsg(TAWrvRequest* pRequest)
{
pRequest->setHttpReplyHeader("content-type", _contentType);
if(_dataRvmsgType == TIBRVMSG_STRING)
{
pRequest->reply((char*)_data);
}
else if(_dataRvmsgType == TIBRVMSG_OPAQUE)
{
pRequest->reply(_data, _dataLen);
}
}
FileService::~FileService()
{
if(_data)free(_data);
}
if(argc < 4)
{
printf("usage: %s <listen subject> <file path> <content-type>\n",
argv[0]);
exit(-1);
}
char* subject = argv[1];
char* filePath = argv[2];
char* contentType = argv[3];
TibrvStatus status;
return 0;
}
This is a service pool example. Depending on the command line argument given, the
service will return a language-specific greeting. If you run multiple instances of this
service, each replying in a different language, requests will be randomly distributed to
worker services by the RVDQ scheduler, and you will see greetings in different languages
if you make multiple requests.
This runs three instances in the background. The listen subject, taw.worldhello is
hardcoded into the program.
If /servlet/TAW is the URL mapping in your web browser type:
http://<your web server>/servlet/TAW?subject=taw.worldhello
Each time you do so, you will see either Hello, Bonjour or Konnichiwa in your browser.
Source Code
The worldhello.cc file where the service pool is defined is given next. In the code, the
basic steps are to:
Derive a subclass from TAWrvService that provides an implementation of the abstract
method onRequest.
Invoke the onMsg() method whenever a request is received. This implementation
returns a greeting in either Japanese, English, or French according to command line
arguments.
Provide a properly initialized TibRvCmQueueTransport to your constructor.
These four parameter definitions determine how RVDQ decides when to promote a
worker to scheduler. See the TIB/Rendezvous documentation for more details on
these parameters.
worldhello.cc
#include "rv6/TAWrv.h"
#include "stdlib.h"
#include "stdio.h"
WorldHelloService(TibrvCmQueueTransport *pRvCmqTransport,
TibrvQueue *pQueue,
const char* requestSubject,
int iGreetingNumber);
~WorldHelloService(){};
void onMsg(TAWrvRequest* pRequest);
protected:
int _iGreetingNumber;
};
WorldHelloService::WorldHelloService(TibrvCmQueueTransport
*pRvCmqTransport, TibrvQueue *pQueue, const char* requestSubject, int
iGreetingNumber)
: TAWrvService(pRvCmqTransport, pQueue, requestSubject)
{
_iGreetingNumber = iGreetingNumber % NUMGREETINGS;
}
void
WorldHelloService::onMsg(TAWrvRequest* pRequest)
{
char buf[512];
sprintf(buf, "<html><body><h2>%s</body></html>",
greetings[_iGreetingNumber]);
pRequest->setHttpReplyHeader("content-type","text/html");
pRequest->reply(buf);
};
TibrvStatus status;
TibrvNetTransport rvTransport;
if ((status = rvTransport.create(rvService, rvNetwork, rvDaemon)) !=
TIBRV_OK) {
printf ("cannot create TibrvNetTransport : %s.\n", status.getText());
exit(-1);
}
TibrvCmQueueTransport rvCmqTransport;
if ((status = rvCmqTransport.create(&rvTransport, RVDQ_SERVICE_POOL))
!= TIBRV_OK) {
printf ("cannot create TibrvCmQueueTransport : %s.\n",
status.getText());
exit(-1);
}
/*
* Instantiate WorldHelloService and have constructor set up the default
* event queue
*/
WorldHelloService worldHelloService (&rvCmqTransport,
(TibrvQueue*)0,
RVDQ_LISTEN_SUBJECT,
gNum);
if(! worldHelloService.isValid())
{
return 0;
}
This is another service pool example. This shows how an initial request can be directed to
a worker service by the RVDQ scheduler, and how the direct request subject is used to
bypass the RVDQ scheduler for subsequent requests from the same client. In addition to
returning a language-specific greeting like worldhello.cc, this service also returns a
hyperlink that contains the direct request subject. When this hyperlink is clicked, the
client communicates directly with the service instance that provided the greeting page.
This idiom is useful when you need to maintain a session between client and service, as
well as between fault tolerant and load balanced services.
This runs three instances in the background. The listen subject, taw.hellogoodbye is
hardcoded into the program.
If /servlet/TAW is the URL mapping in your web browser type:
http://<your web server>/servlet/TAW?subject=taw.hellogoodbye
Each time you do so, you will see either Hello, Bonjour or Konnichiwa in your browser,
just as you did with worldhello.
Now, if you click “Now say goodbye.”, the URL behind this link causes a request to be
made using the direct request subject. The same service instance that responded with the
greeting will now say goodbye in the same language.
Source Code
The hellogoodbye.cc file where the service pool is defined is given next. In the code, the
basic steps are to:
Derive a subclass from TAWrvService that provides an implementation of the abstract
method onMsg().
The onMsg() method is invoked by TAW whenever a request is received. This
implementation returns a greeting in either Japanese, English, or French according to
command line arguments. It also computes a direct request subject that is used to
prepare a hyperlink that uses this subject to recontact this service instance.
The onDirectMsg() method is invoked by TAW whenever a request to the direct
request subject is received. It will return Goodbye in the same language that it used to
return Hello.
You must provide a properly initialized TibRvCmqueueTransport to your constructor.
These four parameter definitions determine how RVDQ decides when to promote a
worker to scheduler. See the TIB/Rendezvous documentation for more details on
these parameters.
Create an instance of HelloGoodbyeService that uses a command line argument to
determine which language to use for hello and goodbye.
After instantiating your TAWrvService subclass, you should make sure that it is valid
before proceeding further. The isValid method is used for this purpose.
If the object is not valid, the reason may be determined by invoking the getErrorMsg
method.
Start request processing.
hellogoodbye.cc
#include "rv6/TAWrv.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#define NUMGREETINGS 5
~HelloGoodbyeService(){};
void onMsg(TAWrvRequest* pRequest);
void onDirectMsg(TAWrvRequest* pRequest);
protected:
int _iGreetingNumber;
};
HelloGoodbyeService::HelloGoodbyeService(TibrvCmQueueTransport
*pRvCmqTransport, TibrvQueue *pQueue, const char* requestSubject, int
iGreetingNumber,int uniqueId)
: TAWrvService(pRvCmqTransport, pQueue, requestSubject)
{
// Determine which greeting to return
_iGreetingNumber = iGreetingNumber % NUMGREETINGS;
TibrvStatus status;
TibrvNetTransport rvTransport;
if ((status = rvTransport.create(rvService, rvNetwork, rvDaemon)) !=
TIBRV_OK) {
printf ("cannot create TibrvNetTransport : %s.\n", status.getText());
exit(-1);
}
TibrvCmQueueTransport rvCmqTransport;
if ((status = rvCmqTransport.create(&rvTransport, RVDQ_SERVICE_POOL))
!= TIBRV_OK) {
printf ("cannot create TibrvCmQueueTransport : %s.\n",
status.getText());
exit(-1);
}
/*
* Instantiate HelloGoodbyeService and have a constructor set up the
* default event queue
*/
HelloGoodbyeService helloGoodbyeService(&rvCmqTransport,
(TibrvQueue*)0, RVDQ_LISTEN_SUBJECT, gNum, uniqueId);
if(!helloGoodbyeService.isValid())
{
printf("TAWrvService constructor failed - %s\n",
helloGoodbyeService.getErrorMsg());
exit(-1);
}
printf("listening to %s for requests\n", RVDQ_LISTEN_SUBJECT);
if(! helloGoodbyeService.enableRequests() ) {
printf("Unable to enable request processing - %s\n",
helloGoodbyeService.getErrorMsg());
}
else {
helloGoodbyeService.fence(); // wait forever
}
return 0;
}
The multidispatcher service example illustrates how to create more than one dispatcher
thread to dispatch events from the queue. Typically one dispatcher thread is used to
dispatch events. By creating multiple dispatcher threads, it allows multiple requests to be
processed simultaneously.
multiDispatcher taw.dispatch.three 3
3. Create multiple browser windows with task.html (for example, three windows)
4. Fill in the subject taw.dispatch.one, job number, processing time. For example:
job number 1001, processing time 10
and submit the forms with jobs all at once (=1001,1002,1003 consecutively).
The sequence of replying from the browser is 1001,1002,1003 with the time displayed.
5. Replace the subject with taw.dispatch.three and submit the forms again.
You will notice the sequence of reply from the browser is in different order, most likely
1003, 1002, 1001 because the processing time for job number 1003 is the least and we have
three threads to handle the tasks.
Source Code
The multiDispatcher.cc file is defined is given next.
multiDispatcher.cc
#include "rv6/TAWrv.h"
#include "stdio.h"
#include "time.h"
void
MultiDispatcherService::onMsg(TAWrvRequest* pRequest)
{
char timeStr[50];
time_t responseTime;
const char* jobid;
int processingTime;
char buf[100];
processingTime = pRequest->getUrlParameter("processingTime") ?
atoi(pRequest->getUrlParameter("processingTime")) : -1;
pRequest->setHttpReplyHeader("content-type","text/plain");
pRequest->reply(buf);
TibrvStatus status;
TibrvQueue queue;
//
// Instantiate MultiDispatcherService, pass the event queue created
// to the constructor and has constructor set up a transport object
//
MultiDispatcherService multiDispatcherService((TibrvTransport*)0,
&queue, subject);
if (! multiDispatcherService.isValid())
{
printf("TAWrvService constructor failed - %s\n",
multiDispatcherService.getErrorMsg());
exit(-1);
}
//
// Create more dispatcher threads and associate them to the queue
// TAWrvService internally would create one dispatcher thread
//
if (! multiDispatcherService.enableRequests() ) {
printf("Unable to enable request processing - %s\n",
multiDispatcherService.getErrorMsg());
}
else {
multiDispatcherService.fence(); // wait forever
}
return 0;
}
The simple service registry example demonstrates the service registry functionality of the
servlet. For example, when you start three programs,
simplesvcReg svc server.1 "response from server 1"
simplesvcReg svc server.2 "response from server 2"
simplesvcReg svc server.3 "response from server 3"
The programs register to the servlet as the service svc and listen on request subjects of
server.1, server.2, and server.3.
heartbeat subject is the heartbeat subject name the service instance is publishing
constantly, telling the servlet that it is up for service,
announce subject is the announce subject name that the servlet announces itself that it is
up, so that service instance will be aware and send a heartbeat in response to the
announce.
If the two subjects are not specified, the default is used.
Source Code
The simplesvcReg.cc file is given next.
simplesvcReg.cc
#include "rv6/TAWrv.h"
#include "rv6/APSvc.h"
#include "stdlib.h"
#include "string.h"
private:
const char* _replyString;
APSvc* _pServiceRegistry;
};
SimpleServiceReg::SimpleServiceReg(TibrvTransport *pRvTransport,
TibrvQueue *pQueue,
const char* serviceName,
const char* requestSubject,
const char* replyString,
const char* hbSubj,
const char* annSubj,
double hbInt,
double failInt)
: TAWrvService(pRvTransport, pQueue, requestSubject),
_replyString(replyString)
{
const TibrvTransport *pTransport = getTibrvTransport();
/*
* Instantiate APSvc class that implements the heartbeat protocol for TAW
* service registry
*/
};
void
SimpleServiceReg::onMsg(TAWrvRequest* pRequest)
{
pRequest->reply(_replyString);
}
TibrvStatus status;
/*
* Instantiate SimpleService and have constructor setup a transport
* object and the default event queue
*/
SimpleServiceReg simpleServiceReg((TibrvTransport*)0,
(TibrvQueue*)0,
serviceName,
serviceSubject,
replyString,
hbSubj, annSubj,
hbInt, failInt);
if(!simpleServiceReg.isValid())
{
printf("TAWrvService constructor failed - %s\n",
simpleServiceReg.getErrorMsg());
exit(-1);
}
return 0;
}
This chapter describes the Java API for TIB/Rendezvous 6.x. Use this API to write
TIB/Adapter for Web service instances when linking to TIB/Rendezvous 6.x. With this
API you can also create a service pool and use TIB/Rendezvous version 6.x distributed
queues or the TAW service registry to load balance requests to service pool members.
Topics
Overview
Your TIB/Adapter for Web service instances must perform the following basic steps:
1. Make sure that taweb.jar and tibrvj.jar are in your CLASSPATH. If your
applications use the service registry, svcreg.jar must also be in your CLASSPATH.
2. Create a subclass of TAWrvService that implements TAWrvService::onMsg(). Inside
onMsg(), arrange for one of the TAWrvRequest::reply() methods to return data to
the servlet.
3. In your subclass main program, instantiate your TAWrvService subclass, and then call
its enableRequests() method to begin listening for requests.
The example programs, SimpleSvc and FileSvc illustrate this basic structure. They also
show how to handle non-text data and manipulate HTTP reply headers.
Service Pools
In some applications, the request rate can exceed the capacity of a single service instance.
A service pool is a fault-tolerant and load-balanced collection of services.
TIB/Rendezvous Distributed Queues (RVDQ) ensure that a request is delivered to only
one pool member. The service registry API can also be used for load balancing. See
Building Service Instances on page 4 for an overview of both methods.
The TAW Java API makes it very convenient to set up service pools. For more information
on setting up service pools, see RVDQ Service Pools on page 316.
Classes
There are three classes that you need to know to use the Java API.
com.tibco.portal.gw.web.api.rv6.TAWrvService
com.tibco.portal.gw.web.api.rv6.TAWrvRequest
com.tibco.portal.gw.web.api.rv6.TAWrvException
The interface for these classes are described in this chapter.
Use the following interface and class to call the service registry API:
com.tibco.portal.svcreg.APSvc
com.tibco.portal.svcreg.APSvcImpl
SimpleSvc. This is a glorified "Hello World!" program that allows you to specify the
subject the service will listen for requests on, and the string it will return. See Simple
Service C++ Example on page 105 for details.
FileSvc. This shows how to transmit string or binary data and set HTTP reply
headers. See File Service C++ Example on page 108 for details.
WorldHello. This is a service pool example. Depending on the command line
argument given, the service will return a language-specific greeting. See WorldHello
Java Example on page 185 for details.
HelloGoodbye. This is another service pool example. This shows how an initial
request can be directed to a worker service by the RVDQ scheduler, and how the
direct request subject is used to bypass the RVDQ scheduler for subsequent requests
from the same client. See HelloGoodbye Java Example on page 187 for details.
MultiDispatcher. This example illustrates how to create more than one dispatcher
thread to dispatch events from the queue. Typically one dispatcher thread is used to
dispatch events. By creating multiple dispatcher threads, it allows multiple requests
to be processed simultaneously. See MultiDispatcher Service Java Example on page
190 for details.
SimplesvcReg. This example demonstrates the service registry functionality of the
servlet. See Simple Service Registry Java Example on page 193 for details.
RawSvc. This example demonstrates using TIB/Rendezvous directly instead of using
the TAW API. See Raw Service Java Example on page 196 for details.
com.tibco.portal.gw.web.api.rv6.TAWrvService
RV 6.x only
Class
java.lang.Object
com.tibco.portal.gw.web.api.rv6.TAWrvService
Declaration
public abstract class TAWrvService extends java.lang.Object
implements com.tibco.tibrv.TibrvMsgCallback
Purpose
TAWrvService is an abstract base class that all TAW service instances must subclass. Your
subclass must implement the onMsg() method that is invoked whenever a request is
received from TIB/Rendezvous. The onMsg() method will receive TAWrvRequest objects
that contain all of the HTTP information about the request as well as any data.
Member Summary
Inherited Methods
The following methods are inherited from java.lang.Object:
clone
equals
finalize
getClass
hashCode
notify
notifyAll
toString
wait
TAWrvService()
RV 6.x only
Constructor
Declarations
public TAWrvService() throws com.tibco.tibrv.TibrvException
public TAWrvService(com.tibco.tibrv.TibrvCmQueueTransport
cmqQueueTransport) throws com.tibco.tibrv.TibrvException
public TAWrvService(com.tibco.tibrv.TibrvCmTibrvTransport
cmqQueueTransport, TibrvQueue queue) throws
com.tibco.tibrv.TibrvException
public TAWrvService(com.tibco.tibrv.TibrvCmQueueTransport
cmqQueueTransport, TibrvQueue queue, java.lang.String requestSubject)
throws com.tibco.tibrv.TibrvException,
com.tibco.portal.gw.web.TAWException
public TAWrvService(com.tibco.tibrv.TibrvCmQueueTransport
cmqQueueTransport, TibrvQueue queue, java.lang.String requestSubject,
java.lang.String directRequestSubject) throws
com.tibco.tibrv.TibrvException, com.tibco.portal.gw.web.TAWException
Purpose
Constructors for the TAWrvService class.
Name Description
Name Description
Name Description
Name Description
Remarks
All applications must provide a subclass of TAWrvService that implements the onMsg
method.
Subjects need not be specified here, but must be set prior to enabling the service.
Example
public class SimpleSvc extends TAWrvService
{
public static void main(String argv[])
{
try
{ ...
{
Tibrv.open(Tibrv.IMPL_NATIVE);
SimpleSvc svc = new SimpleSvc();
[truncated...]
Errors
An error will throw an exception:
try { ...
} catch(Exception ...)
TAWrvService.get...() Accessors
RV 6.x only
Methods
Declaration
public java.lang.String getDirectRequestSubject()
public java.lang.String getDispatchQueue()
public java.lang.String getRequestSubject()
public com.tibco.tibrv.TibrvCmQueueTransport getTibrvCmQueueTransport()
public com.tibco.tibrv.TibrvTransport getTibrvTransport()
Purpose
Accessor methods for TAWrvServices instances.
Name Description
TAWrvService.onMsg()
RV 6.x only
Method
Declaration
public abstract void onMsg(TAWrvRequest request)
Purpose
All applications must provide a subclass of TAWrvService that implements the onMsg()
method. The method is called when a request is received from TIB/Rendezvous on the
primary request subject.
Parameters
Name Description
TAWrvService.onDirectMsg()
RV 6.x only
Method
Declaration
public void onDirectMsg(TAWrvRequest request);
Purpose
This method is only relevant to RVDQ-based service instances. This method is called
when a request is received on the direct request subject. Requests to direct request
subjects are not intercepted by the RVDQ scheduler. The default implementation merely
invokes the onMsg() method.
Parameters
Name Description
TAWrvService.setRequestSubject()
RV 6.x only
Method
Declaration
public void setRequestSubject(java.lang.String subject)
throws TAWException
Purpose
Determines which subject the service will listen, either for normal, reliable requests, or for
RVDQ-based requests.
Parameters
Name Description
Remarks
An exception is thrown when the request subject is null.
TAWrvService.setDirectRequestSubject()
RV 6.x only
Method
Declaration
public void setDirectRequestSubject(java.lang.String subject);
Purpose
Determines which subject the service will use to listen for requests that are not subject to
RVDQ load-balancing. The method only applies RVDQ-based services.
Parameters
Name Description
TAWrvService.enableRequests()
RV 6.x only
Method
Declaration
public void enableRequests() throws TAWException
Purpose
Before the service will start receiving requests through its onMsg() method, the
enableRequests() method must be invoked. This sets up the necessary TIB/Rendezvous
listeners.
Parameters
None.
Remarks
Prior to invoking enableRequest(), you must have set the subjects that your service will
accept requests on. You can do this in the constructor, or use setRequestSubject() and
setDirectRequestSubject(). This method creates TibrvListener objects that remain
valid until the disableRequests() method is invoked.
An exception is thrown if no requestSubject has been set, or if a TIB/Rendezvous listener
cannot be created.
TAWrvService.disableRequests()
RV 6.x only
Method
Declaration
public void disableRequests();
Purpose
This method allows the service to suspend request processing. This method causes the
service to stop listening for requests.
Remarks
This method destroys the TibrvListener objects created in enableRequests().
Parameters
None.
TAWrvService.isEnabled()
RV 6.x only
Method
Declaration
public boolean isEnabled();
Purpose
Determines whether the service is currently listening for requests.
Remarks
Returns TRUE if the service is currently listening for requests or FALSE if it is not.
com.tibco.portal.gw.web.api.rv6.TAWrvRequest
RV 6.x only
Class
java.lang.Object
com.tibco.portal.gw.web.api.rv6.TAWrvRequest
Declaration
public class TAWrvRequest extends java.lang.Object
Purpose
TAWrvRequest objects are manufactured by the TIB/Adapter for Web API when requests
are received. This class encapsulates an HTTP request from the time it is delivered to your
service instance, to after your reply has been transmitted. Its interface consists primarily
of accessors for HTTP protocol information, including the data payload. The reply
method is used to send data back to the browser or other HTTP client.
These objects are created and destroyed by TAW, and are made available to you through
the TAWrvService member callback functions onMsg() and onDirectMsg().
Member Summary
Inherited Methods
The following methods are inherited from java.lang.Object:
clone
equals
finalize
getClass
hashCode
notify
notifyAll
toString
wait
TAWrvRequest()
RV 6.x only
Constructor
Declarations
public TAWrvRequest(com.tibco.tibrv.TibrvMsg msg,
com.tibco.tibrv.TibrvTransport transport)
Purpose
Sets up an object that is used to respond to a request.
Although a constructor is provided, it typically is not used because the object is created
internally during the callback.
Parameters
Name Description
TAWrvRequest.get...() Accessors
RV 6.x only
Methods
Declaration
// ----------------- Request ------------------
public java.lang.String getHttpHeader(java.lang.String name) throws
TAWException
public com.tibco.tibrv.TibrvMsg getHttpHeaders() throws TAWException
public java.lang.String getHttpMethod() throws TAWException
public java.lang.String getHttpUri() throws TAWException
public java.lang.String getHttpVersion() throws TAWException
public int getProtocolVersion()
public java.lang.String getUrlParameter(java.lang.String name)
public com.tibco.tibrv.TibrvMsg getUrlParameters() throws TAWException
public java.lang.String getUrlPath() throws TAWException
public java.lang.String getUrlResource() throws TAWException
public int getProtocolVersion() throws TAWException
// ----------------- Reply------------------
public java.lang.Object getHttpReplyEntityBody() throws TAWException
public java.lang.Object getHttpReplyHeader(java.lang.String name)
public com.tibco.tibrv.TibrvMsg getHttpReplyHeaders() throws TAWException
public java.lang.String getHttpReplyReasonPhrase()
public int getHttpReplyStatusCode()
public TibrvMsg getReplyMsg() throws TAWException
public java.lang.String getReplyProtocolVersion()
Purpose
The next table lists the request accessors for TAWrvRequest instances.
getHttpMethod() Returns the HTTP method from the HTTP request line.
An exception is thrown if the HTTP method field is not
found.
getHttpUri() Returns the HTTP URI from the HTTP request line.
An exception is thrown if the HTTP Uri is not found.
getHttpVersion() Returns the HTTP version from the HTTP request line.
An exception is thrown if the HTTP version field is not
found.
getUrlParameters() Returns all query parameters from the URL on the request
line. It returns a TibrvMsg containing one field for each
parameter.
An exception is thrown if the URL parameter fields are not
found.
getUrlPath() Returns the path from the HTTP request line. An exception
is thrown if the value of the corresponding TibrvMsg field is
not a string.
An exception is thrown if the URL path field is not found.
The next table lists the reply accessors for TAWrvRequest instances.
getHttpReplyEntityBody() Returns the reply entity body object that needs to be cast to
the appropriate type (String or byte[]).
An exception is thrown if the entity body is null.
getHttpReplyHeader(name) Returns the object for a given Http Header, given the name
of field to get. The lookup is case insensitive.
If multiple values are associated with the headers of the
same name, only one value will return. Use
getHttpReplyHeaders() to manually get all the values.
name—String. Name of field to get.
TAWrvRequest.reply...()
RV 6.x only
Methods
Declaration
public void reply() throws TAWException
public void reply(byte[] entityBody) throws TAWException
public void reply(byte[] entityBody, int statusCode) throws TAWException
public void reply(byte[] entityBody, int statusCode, java.lang.String
reasonPhrase) throws TAWException
public void reply(java.lang.String entityBody) throws TAWException
public void reply(java.lang.String entityBody, int statusCode) throws
TAWException
public void reply(java.lang.String entityBody, int statusCode,
java.lang.String reasonPhrase) throws TAWException
Purpose
Send a reply back to the HTTP client. The next table lists and explains the reply() methods.
Name Description
reply() Sends a reply back to the HTTP client through the web
browser when all HTTP reply information, including reply
data has been set via TAWrvRequest accessor methods.
An exception is thrown if a TIB/Rendezvous error occurs
during the reply transmission.
reply(entityBody, statusCode) Sends a reply containing binary data back to the HTTP
client through the web browser. The default HTTP reason
phrase ("OK") is used.
entityBody—byte[]. Binary data
statusCode—Int. HTTP reply status code
An exception is thrown if a TIB/Rendezvous error occurs
during the reply transmission.
Name Description
reply(entityBody, statusCode, This method is used to send a reply containing binary data
reasonPhrase) back to the HTTP client through the web browser.
entityBody—byte[]. Binary data
statusCode—Int. HTTP reply status code
reasonPhrase—String. HTTP reply reason phrase
An exception is thrown if a TIB/Rendezvous error occurs
during the reply transmission.
reply(entityBody) Sends a reply containing string data back to the HTTP client
through the web browser. The default HTTP reply status
code (200) and reason phrase ("OK") are used.
entityBody—String. String data
An exception is thrown if a TIB/Rendezvous error occurs
during the reply transmission.
reply(entityBody, statusCode) Sends a reply containing string data back to the HTTP client
through the web browser. The default HTTP reason phrase
("OK") is used.
entityBody—String. String data
statusCode—Int. HTTP reply status code
An exception is thrown if a TIB/Rendezvous error occurs
during the reply transmission.
reply( entityBody, statusCode, Sends a reply containing string data back to the HTTP client
reasonPhrase) through the web browser.
entityBody—String. String data
statusCode—Int. HTTP reply status code
reasonPhrase—String. HTTP reply reason phrase
An exception is thrown if a TIB/Rendezvous error occurs
during the reply transmission.
TAWrvRequest.set...()
RV 6.x only
Methods
Declaration
public void setHttpReplyEntityBody(byte[] body)
public void setHttpReplyEntityBody(java.lang.String body)
public void setHttpReplyHeader(java.lang.String name, int value)
public void setHttpReplyHeader(java.lang.String name, java.lang.String
value)
public void setHttpReplyReasonPhrase(java.lang.String phrase)
public void setHttpReplyStatus(int code, java.lang.String phrase)
public void setHttpReplyStatusCode(int code)
Purpose
Sets a value for TAWrvRequest instances.
Name Description
setHttpReplyEntityBody(body) Sets binary data into the HTTP entity body (i.e. data
payload) of the reply.
body—byte[]. Binary payload data
—or—
body—String. Payload data.
setHttpReplyHeader(name value) Sets the value of a named HTTP header to a value. Any
preexisting value for that header is appended.
name—String. Header name
value—Int. Value of header
—or—
value—String. Value of header
setHttpReplyStatus(code, phrase) Sets the reply HTTP reason phrase and status code.
code—Int. HTTP status code
phrase—String. HTTP reason phrase
Name Description
com.tibco.portal.gw.web.api.rv6.TAWrvException
RV 6.x only
Class
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.tibco.portal.gw.web.api.rv6.TAWException
Declaration
public class TAWException extends java.lang.Exception
Purpose
The TAWrvException class is used to report TAW errors.
Inherited Methods
The following methods are inherited from java.lang.Object:
clone
equals
finalize
getClass
hashCode
notify
notifyAll
toString
wait
The following methods are inherited from java.lang.Throwable:
fillInStackTrace
getLocalizedMessage
getMessage
printStackTrace
toString
com.tibco.portal.svcreg.APSvc
RV 6.x only
Interface
java.lang.Runnable
com.tibco.portal.svcreg.APSvc
Declaration
public interface APSvc
extends java.lang.Runnable
Purpose
This interface is used by a service instance to register itself with all clients that have
embedded an APSvcRegistry instance. It handles the heartbeat protocol.
Member Summary
APSvc.appendToHeartbeat()
RV 6.x only
Method
Declaration
public com.tibco.tibrv.TibrvMsg appendToHeartbeat()
Purpose
The method is called just before a heartbeat is emitted. An implementation is mandatory.
The method returns a TibrvMsg containing auxiliary information to be associated with this service
instance in the client's APSvcRegistry, or null.
APSvc.disable()
RV 6.x only
Method
Declaration
public void disable()
throws com.tibco.tibrv.TibrvException
Purpose
Inform all APSvcRegistry instances that this service instance is temporarily disabled and
unable to receive requests.
APSvc.enable()
RV 6.x only
Method
Declaration
public void enable()
throws com.tibco.tibrv.svcreg.TibrvException
Purpose
Informs all APSvcRegistry instances that this service instance is ready to receive
requests.
APSvc.init()
RV 6.x only
Method
Declaration
public void init(java.lang.String serviceName,
java.lang.String requestSubject,
com.tibco.tibrv.TibrvTransport heartbeatTransport,
java.lang.String heartbeatSubject,
double heartbeatInterval,
double failureTolerance,
java.lang.String registrySubject,
byte readyStatus)
throws com.tibco.portal.svcreg.APSvcException,
com.tibco.tibrv.TibrvException
Purpose
Initialize a service registry instance .
Parameters
Name Description
APSvc.run()
RV 6.x only
Method
Declaration
public void run()
Purpose
This method must be implemented by its subclass. When an object implementing
Runnable is used to create a thread, starting the thread causes the object’s run method to
be called in that separately executing thread.
APSvc.terminate()
RV 6.x only
Method
Declaration
public void terminate()
throws com.tibco.tibrv.TibrvException
Purpose
Inform all APSvcRegistry instances that this service instance has exited.
com.tibco.portal.svcreg.APSvcImpl
RV 6.x only
Class
java.lang.Object
com.tibco.portal.svcreg.APSvcImpl
Declaration
public class APSvcImpl
implements com.tibco.portal.svcreg.APSvc
com.tibco.tibrv.TibrvTimerCallback
com.tibco.tibrv.TibrvMsgCallback
Purpose
The APSvcImpl class implements the APSvc heartbeat protocol interface.
Member Summary
APSvcImpl.APSvcImpl()
RV 6.x only
Constructor
Declaration
public APSvcImpl(java.lang.String serviceName,
java.lang.String requestSubject,
com.tibco.tibrv.TibrvTransport heartbeatTransport,
java.lang.String heartbeatSubject,
double heartbeatInterval,
double failureTolerance,
java.lang.String registrySubject,
byte readyStatus)
throws com.tibco.portal.svcreg.APSvcException,
com.tibco.tibrv.TibrvException
Purpose
Create a service registry instance.
Parameters
Name Description
APSvcImpl.appendToHeartbeat()
RV 6.x only
Method
Declaration
public com.tibco.tibrv.TibrvMsg appendToHeartbeat()
Purpose
The method is called just before a heartbeat is emitted. The method allows you to append any
auxiliary information to be associated with this service instance in the client's APSvcRegistry by
overriding this method.
The method returns a TibrvMsg containing auxiliary information. The current implementation
returns null.
APSvcImpl.disable()
RV 6.x only
Method
Declaration
public void disable()
throws com.tibco.tibrv.TibrvException
Purpose
Inform all APSvcRegistry instances that this service instance is temporarily disabled and
unable to receive requests.
APSvcImpl.enable()
RV 6.x only
Method
Declaration
public void enable()
throws com.tibco.tibrv.TibrvException
Purpose
Informs all APSvcRegistry instances that this service instance is ready to receive
requests.
APSvcImpl.init()
RV 6.x only
Method
Declaration
public void init(java.lang.String serviceName,
java.lang.String requestSubject,
com.tibco.tibrv.TibrvTransport heartbeatTransport,
java.lang.String heartbeatSubject,
double heartbeatInterval,
double failureTolerance,
java.lang.String registrySubject,
byte readyStatus)
throws com.tibco.portal.svcreg.APSvcException,
com.tibco.tibrv.TibrvException
Purpose
Initialize a service registry instance . This method is implemented for interface
com.tibco.portal.svcreg.APSvc. It is called by the
com.tibco.portal.svcreg.APSvcImpl constructor. Typically users should not call this
method.
Parameters
Name Description
Name Description
APSvcImpl.onMsg()
RV 6.x only
Method
Declaration
public void onMsg(com.tibco.tibrv.TibrvListener listener,
com.tibco.tibrv.svcreg.TibrvMsg msg)
Purpose
Respond to an announcement message from an APSvcRegistry by sending a heartbeat.
This method is implemented for interface com.tibco.tibrv.TibrvMsgCallback. It will
be called when there is an incoming message with the request subject. You need not call
this method.
Parameters
Name Description
APSvcImpl.onTimer()
RV 6.x only
Method
Declaration
public void onTimer(com.tibco.tibrv.TibrvTimer timer)
Purpose
Process timer events.
This method is implemented for interface com.tibco.tibrv.TibrvTimerCallback. It
will be called when there is a timer event. You need not call this method.
Parameter
Name Description
APSvcImpl.run()
RV 6.x only
Method
Declaration
public void run()
Purpose
This method is implemented for interface java.lang.Runnable. It will be called when
you create this instance. You need not call this method.
APSvcImpl.sendHeartbeat()
RV 6.x only
Method
Declaration
public void sendHeartbeat()
throws com.tibco.tibrv.TibrvException
Purpose
Send a heartbeat, called internally, by responding to an announcement message from an
APSvcRegistry. You can invoke this method to explicitly send a heartbeat.
APSvcImpl.startHeartbeating()
RV 6.x only
Method
Declaration
public void startHeartbeating()
throws com.tibco.tibrv.TibrvException
Purpose
Starts sending periodic heartbeats by activating a timer. The method is normally called by
APSvcImpl.run() and not typically called directly. This call should be invoked only after
a service instance is disabled and then enabled.
APSvcImpl.terminate()
RV 6.x only
Method
Declaration
public void terminate()
throws com.tibco.tibrv.TibrvException
Purpose
Inform all APSvcRegistry instances that this service instance has exited.
This program allows you to specify the subject the service will listen for requests on, and
the string it will return.
Source Code
The SimpleSvc.java file where the simple service is defined is listed next. In the code,
the basic steps are to:
All service instances must subclass TAWrvService and implement the abstract request
callback member function onMsg().
A TAWrvRequest object is created by TAW when a request is received and is delivered
to an application through the onMsg method. The reply member of TAWrvRequest is
used to transmit the reply string to the client.
In main, a SimpleSvc instance is first created. Then its request subject, and the string
to provide in the reply are set. Finally, requests are enabled.
TAWrvRequest object contain an invisible “return address” that is used by the reply
method to return data to the client through the servlet.
SimpleSvc.java
import com.tibco.portal.gw.web.api.rv6.*;
import com.tibco.tibrv.*;
This shows how to transmit string or binary data and set HTTP reply headers.
Source Code
The FileSvc.java file where the simple service is defined is given next. In the code, the
basic steps are to:
All service instances must subclass TAWrvService and implement the abstract request
callback member function onMsg().
A TAWrvRequest object is created by TAW when a request is received and is delivered
to an application through the onMsg() method. The reply member of TAWrvRequest
is used to transmit the reply string to the client. An HTTP “content-type” reply
header is set from the command-line-specified value which should be chosen to reflect
the type of file. Next, the appropriate form of reply is used to transmit the file contents
back to the client.
In main, a SimpleSvc instance is created. The desired request subject and content type
are set from command line parameters. The specified file is loaded into a buffer, and if
it is either a .gif or .jpg file, the file is considered a binary file. Finally, requests are
enabled.
When a request is received, the contents of the file are returned to the client using the
appropriate form of reply() for the type of file.
FileSvc.java
import java.io.*;
import com.tibco.portal.gw.web.api.rv6.*;
import com.tibco.tibrv.*;
try {
request.setHttpReplyHeader("content-type", contentType);
if(isBinaryFile)
request.reply(bytes);
else
request.reply(new String(bytes));
} catch(Exception e) {
System.out.println("onMsg: "+e);
}
}
private int bytesRead;
private byte[] bytes;
private String contentType;
private boolean isBinaryFile;
}
This is a service pool example. Depending on the command line argument given, the
service will return a language-specific greeting. If you run multiple instances of this
service, each replying in a different language, requests will be randomly distributed to
worker services by the RVDQ scheduler, and you will see greetings in different languages
if you make multiple requests.
Source Code
The WorldHello.java file where the service pool is defined is given next. In the code, the
basic steps are to:
All service instances must subclass TAWrvService and implement the abstract request
callback member function onMsg().
Create an instance of WorldHello using the RVDQ session just created. Setup reply
data hash table and finally enable requests.
When a request is received, the onMsg() method looks up the appropriate greeting in
the hash table and invokes request's reply method to send it back to the client.
WorldHello.java
import java.util.*;
import com.tibco.portal.gw.web.api.rv6.*;
import com.tibco.tibrv.*;
public class WorldHello extends TAWrvService {
private static final String rvdqListenSubject = "taw.worldhello";
private static final String servicePool = "WorldHello";
This is another service pool example. This shows how an initial request can be directed to
a worker service by the RVDQ scheduler, and how the direct request subject is used to
bypass the RVDQ scheduler for subsequent requests from the same client. In addition to
returning a language-specific greeting like worldhello, this service also returns a
hyperlink that contains the direct request subject. When this hyperlink is clicked on, the
client communicates directly with the service instance that provide the greeting page.
Source Code
The HelloGoodbye.java file where the service pool is defined is given next. In the code,
the basic steps are to:
Subclass TAWrvService and implement the abstract request callback member
function onMsg().
Construct a unique direct request subject by concatenating the identifier specified on
the command line with the request subject and provide it to the service instance. Setup
the reply hash tables and finally enable requests.
Initial requests from a client are delivered to the service through the onMsg() method.
This method builds an HTML page that consists of a hyperlink that displays as hello
or foreign language equivalent. The URL in this link embeds the direct request subject
so that when the link is followed, a request will be sent to the service's direct request
subject. This page is then returned to the client.
The onDirectMsg() method will never be invoked on the initial client request. It is
only invoked after the service has returned the hello page described above, and after
the user has clicked on the link. In response, the same language that was used to say
hello will be used to prepare a goodbye page.
HelloGoodbye.java
import java.util.*;
import com.tibco.portal.gw.web.api.rv6.*;
import com.tibco.tibrv.*;
//
// Instantiate HelloGoodbye Service and set up the default
// event queue
//
HelloGoodbye svc = new HelloGoodbye(qt, null, rvdqListenSubject, s);
svc.language = argv[0];
The multidispatcher service example illustrates how to create more than one dispatcher
thread to dispatch events from the queue. Typically one dispatcher thread is used to
dispatch events. By creating multiple dispatcher threads, it allows multiple requests to be
processed simultaneously.
3. Create multiple browser windows with task.html (for example, three windows)
4. Fill in the subject taw.dispatch.one, job number, processing time. For example:
job number 1001, processing time 10
and submit the forms with jobs all at once (=1001,1002,1003 consecutively).
The sequence of replying from the browser is 1001,1002,1003 with the time displayed.
5. Replace the subject with taw.dispatch.three and submit the forms again.
You will notice the sequence of reply from the browser is in different order, most likely
1003, 1002, 1001 because the processing time for job number 1003 is the least and we have
three threads to handle the tasks.
Source Code
The MultiDispatcher.java file is defined is given next.
import com.tibco.portal.gw.web.api.rv6.*;
import com.tibco.tibrv.*;
import java.util.*;
if(argv.length < 2 )
System.out.println("usage: java MultiDispatcher <listen subject>
<number of dispatchers>");
else
{
Tibrv.open(Tibrv.IMPL_NATIVE);
//
// Instantiate MultiDispatcherService, pass the new event queue
// to the constructor and have the constructor set up a
// transport object
//
MultiDispatcher svc = new MultiDispatcher((TibrvTransport)null,
queue, argv[0]);
System.out.println("Listening on : " + argv[0]);
//
// Create more dispatcher threads and associate them to the queue.
// TAWrvService internally would create one dispatcher thread
//
for (int i=0; i<numDispatcher-1; i++) {
TibrvDispatcher dispatcher = new TibrvDispatcher(tawQueue);
}
svc.enableRequests();
}
}
catch(Exception e)
{
System.out.println("main: "+e);
}
}
request.setHttpReplyHeader("content-type","text/plain");
request.reply(replyStr);
}
catch(Exception e)
{
System.out.println("onMsg: "+e);
}
}
The simple service registry example demonstrates the service registry functionality of the
servlet. For example, when you start three programs,
simplesvcReg svc server.1 "response from server 1"
simplesvcReg svc server.2 "response from server 2"
simplesvcReg svc server.3 "response from server 3"
The programs register to the servlet as the service svc and listen on request subjects of
server.1, server.2, and server.3.
heartbeat subject is the heartbeat subject name the service instance is publishing
constantly, telling the servlet that it is up for service,
announce subject is the announce subject name that the servlet announces itself that it is
up, so that service instance will be aware and send a heartbeat in response to the
announce.
If the two subjects are not specified, the default is used.
Source Code
The SimpleSvcReg.java file is given next.
import com.tibco.portal.svcreg.*;
import com.tibco.portal.gw.web.api.rv6.*;
import com.tibco.tibrv.*;
{
if(argv.length < 3)
System.out.println("usage: java SimpleSvcReg <service name>
<service subject> <reply string> [<heartbeat subject>
<announce subject>]");
else
{
Tibrv.open(Tibrv.IMPL_NATIVE);
svc.setRequestSubject(argv[1]);
svc.replyString = argv[2];
System.out.print("Service name = " + argv[0]);
System.out.print(", Heartbeat subject = " + hbSubj);
System.out.println(", Announce subject = "+ annSubj);
System.out.println("Listening on : " + argv[1]);
System.out.println("Replying with : " + argv[2]);
svc.enableRequests();
}
}
catch(Exception e)
{
System.out.println("main: "+e);
}
}
throws TibrvException
{
super();
try
{
// Start object to handle service registry
serviceRegistry = new APSvcImpl(svcName, svcSubj, getTibrvTransport(),
hbSubj, hbInt, failInt, annSubj, enabledStatus);
new Thread(serviceRegistry).start();
}
catch(Exception e)
{
System.out.println("SimpleSvcReg: "+e);
}
}
The RawSvc service demonstrates using TIB/Rendezvous directly instead of using the
TAW API. The RawSvc service is similar to the Simple service. The program takes in a list
of subjects it is listening on and a reply message. For example, java RawSvc "a.b.c"
"x.y.z" "Hello". Then, when you submit a request from the browser making the subject
equal to either one of them, you will receive a response of "Hello" from the browser
together with the timestamp of when the service replies.
Some platforms require proper quoting of the arguments to prevent the command line
processor from modifying the command arguments. You can terminate the program by
typing Control-C.
You can specify communication parameters for tibrvTransport_Create(). If none are
specified the following defaults are used:
service "rendezvous" or "7500/udp"
network the result of gethostname()
daemon "tcp:7500"
For example:
To listen to every message published on subject a.b.c:
java RawSvc a.b.c
Source Code
The RawSvc.java file is given next.
import java.util.*;
import com.tibco.tibrv.*;
import com.tibco.portal.gw.web.*;
replyMsg = args[args.length-1];
// Open Tibrv in native implementation
try
{
Tibrv.open(Tibrv.IMPL_NATIVE);
}
catch (TibrvException e)
{
System.err.println("Failed to open Tibrv in native
implementation:");
e.printStackTrace();
System.exit(0);
}
TibMsg.add(TAWrvMsgFLD.HTTP_STATUS_CODE, 200);
TibMsg.add(TAWrvMsgFLD.HTTP_REASON_PHRASE, "OK");
TibMsg.add(TAWrvMsgFLD.VERSION_CODE, 40);
TibMsg.add(TAWrvMsgFLD.ENTITY_BODY, msg);
return TibMsg;
} catch (Exception e) {
return null;
}
}
{
daemon = args[i+1];
i += 2;
}
else
usage();
}
return i;
}
This appendix describes the C++ API used with TIB/Rendezvous 5.x. Use this API to
write TIB/Adapter for Web service instances when linking to TIB/Rendezvous 5.x. With
this API you can also create a service pool and use TIB/Rendezvous distributed queues to
load-balance requests to service pool members.
Note: The TAW C++ API for TIB/Rendezvous 5.x is not supported on Windows NT.
Topics
Overview
Use this API to write TIB/Adapter for Web service and service-pool applications. It
provides the capability to easily use TIB/Rendezvous version 5.3 distributed queues to
load-balance requests to service pool members.
The TIB/Adapter for Web distribution contains sample source programs that illustrate
how to write very simple applications as well as more complex RVDQ-based services.
Copies of the sample programs are included in your installation area in the samples
directory.
The Basics
Your TIB/Adapter for Web service instances must perform the following basic steps:
1. Include rv5/TAWrv.h
2. Create a subclass of TAWrvService that implements TAWrvService::onRequest().
Inside onRequest(), arrange for one of the TAWrvRequest::reply() methods to
return data to the servlet.
3. Instantiate your TAWrvService subclass in your main program, and then call its
enableRequests() method to begin listening for requests.
The example programs, simplesvc.cc and filesvc.cc illustrate this basic structure.
They also show how to handle non-text data and manipulate HTTP reply headers. Source
listings are provided in section C++ Example Service Instances for TIB/Rendevous 5.x on
page 243.
Service Pools
In some applications, the request rate can exceed the capacity of a single service instance.
A service pool is a fault-tolerant and load-balanced collection of services.
TIB/Rendezvous Distributed Queues (RVDQ) ensure that a request is delivered to only
one pool member. The TAW C++ API makes it very convenient to set up service pools.
For more information on setting up service pools, see RVDQ Service Pools on page 324.
Classes
There are only two classes that you need to know about to use the C++ API:
TAWrvService
TAWrvRequest
You must create your own subclass of TAWrvService. The onRequest() or
onDirectRequest() methods of this subclass will receive TAWrvRequest objects which
contain all of the HTTP information about the request as well as any data.
TAWrvService
RV 5.x only
Class
Purpose
TAWrvService is an abstract class. Your application needs to create a subclass of
TAWrvService that implements the request callbacks that will be invoked when requests
are received.
Remarks
There are two constructors. The first constructor is used to build standard,
non-load-balancing service instances, using an RvSession. The second constructor is used
to build load-balancing service instances based on TIB/Rendezvous distributed queues,
using an RvCmqSession. If directSubject is specified, requests may be sent directly to
this service instance using that subject, bypassing the RVDQ scheduler.
Member Summary
TAWrvService::TAWrvService()
RV 5.x only
Constructor
Declaration
TAWrvService(RvSession* pRvSession=0,
const char* requestSubject=0);
TAWrvService(RvCmqSession* pRvCmqSession,
const char* requestSubject=0,
const char* directRequestSubject=0);
Purpose
All applications must provide a subclass of TAWrvService that implements the
onRequest method. The first constructor is used to setup normal reliable communications
between the servlet and your application. The second constructor is used to build
RVDQ-based service pools.
Remarks
Subjects need not be specified here, but must be set prior to enabling the service.
Parameters
Name Description
Example
class SimpleService : public TAWrvService
{
public:
SimpleService(RvSession *pRvSession, const char* requestSubject,
const char* replyString)
: TAWrvService(pRvSession, requestSubject),
_replyString(replyString){};
~SimpleService(){};
void onRequest(TAWrvRequest* request);
private:
const char* _replyString;
};
Errors
Use the isValid() member to make sure that the constructor did not fail. For a
descriptive error message string, use the TAWrvService::getErrorMsg() member.
See Also
TAWrvService::isValid(), page 218.
TAWrvService::getErrorMsg(), page 220.
TAWrvService::~TAWrvService()
RV 5.x only
Destructor
Declaration
~TAWrvService();
Purpose
This method destroys the TAWrvService instance from which it is called and releases all
resources.
Remarks
This destructor must be called whenever you are finished with communications between
the servlet and your application.
Parameters
None.
TAWrvService::onRequest()
RV 5.x only
Method
Declaration
virtual void onRequest(TAWrvRequest* pRequest) = 0;
Purpose
All applications must provide a subclass of TAWrvService that implements the
onRequest method. This method is called when a request is received.
Parameters
Name Description
TAWrvService::onDirectRequest()
RV 5.x only
Method
Declaration
virtual void onDirectRequest(TAWrvRequest* pRequest);
Purpose
This method is only relevant to RVDQ-based service instances. This method is called
when a request is received on the direct request subject. Requests to direct request
subjects are not intercepted by the RVDQ scheduler. The default implementation merely
invokes the onRequest() method.
Parameters
Name Description
TAWrvService::setRequestSubject()
RV 5.x only
Method
Declaration
virtual void setRequestSubject(const char* subjectName);
Purpose
Set the subject name used to listen for requests. This subject is used by both RVDQ-based
pooled services, or by singleton applications.
Parameters
Name Description
subjectName Rendezvous subject name that the service will use to listen for
requests.
TAWrvService::setDirectRequestSubject()
RV 5.x only
Method
Declaration
virtual void setDirectRequestSubject(const char* subjectName);
Purpose
Set the subject name used to listen for requests directed at a specific member or members
of an RVDQ-based service pool. This subject is not used by RvSession-based services at
all. RVDQ-based applications can use this subject to get requests without the intervention
of the RVDQ scheduler.
Parameters
Name Description
subjectName RV subject name that the service will use to listen for direct
requests.
TAWrvService::getDirectRequestSubject()
RV 5.x only
Method
Declaration
virtual const char* getDirectRequestSubject();
Purpose
Get the subject name used to listen for requests directed at a specific member or members
of an RVDQ-based service pool. This subject is not used by RvSession-based services at
all. RVDQ-based applications can use this subject to get requests without the intervention
of the RVDQ scheduler.
Parameters
Returns a pointer to the subject name string or NULL. Do not modify or delete this string.
TAWrvService::getRequestSubject()
RV 5.x only
Method
Declaration
virtual const char* getRequestSubject();
Purpose
Get the subject name used to listen for requests. This subject is used by both RVDQ-based
pooled services, or by singleton applications.
Parameters
Returns a pointer to the subject name string or NULL. Do not modify or delete this string.
TAWrvService::enableRequests()
RV 5.x only
Method
Declaration
virtual rv_Boolean enableRequests();
Purpose
Start listening for requests.
Remarks
Prior to invoking enableRequests(), you must set the subjects on which your service
will accept requests. You can do this in the constructor, or use the setRequestSubject()
and setDirectRequestSubject(). This method creates RvListeners that remain valid
until the disableRequests() method is invoked.
Parameters
Returns RV_TRUE if successful, RV_FALSE otherwise.
See Also
TAWrvService::setRequestSubject(), page 211.
TAWrvService::setDirectRequestSubject(), page 212.
TAWrvService::disableRequests(), page 216.
TAWrvService::disableRequests()
RV 5.x only
Method
Declaration
virtual rv_Boolean disableRequests();
Purpose
Stop listening for requests.
Remarks
This method destroys the RvListeners created in enableRequests().
Parameters
Returns RV_TRUE if successful, RV_FALSE otherwise.
TAWrvService::isEnabled()
RV 5.x only
Method
Declaration
virtual rv_Boolean isEnabled();
Purpose
Determine whether the service is currently listening for requests.
Parameters
Returns RV_TRUE if the service is currently listening for requests, RV_FALSE otherwise.
TAWrvService::isValid()
RV 5.x only
Method
Declaration
virtual rv_Boolean isValid();
Purpose
Provide a way for the TAWrvService constructor to report that it failed.
Remarks
Use the getErrorMsg() to determine the reason for the failure.
Parameters
Returns RV_TRUE if the object could be correctly built, RV_FALSE otherwise.
See Also
TAWrvService::getErrorMsg(), page 220.
TAWrvService::getRvSession()
RV 5.x only
Method
Declaration
rv_Session getRvSession();
Purpose
Get the TIB/Rendezvous C language session handle.
Parameters
Returns a pointer to rv_Session embedded in the RvSession object in use.
TAWrvService::getErrorMsg()
RV 5.x only
Method
Declaration
virtual const char* getErrorMsg();
Purpose
Get a string describing what went wrong during an invocation of a TAWrvService
method.
Parameters
Returns a pointer to error description string or NULL.
TAWrvRequest
RV 5.x only
Class
Purpose
TAWrvRequest objects are manufactured when requests are received. They encapsulate all
of the HTTP information in the request, including the communication endpoint to reply
to. Members can be used to access HTTP request information, as well as to prepare a
reply.
Remarks
These objects are created and destroyed by the API and are valid for the duration of one
invocation of your application’s implementation of TAWrvService::onRequest(). You
must copy any data or header information if your application will need them after
onRequest() returns.
Member Summary
TAWrvRequest::getReplySubject()
RV 5.x only
Method
Declaration
virtual const char* getReplySubject();
Purpose
Get the subject name that the TIB/Adapter for Web servlet is listening for your reply on.
Parameters
Returns a pointer to the subject name string or NULL. Do not modify or delete this string.
TAWrvRequest::getUrlPath()
RV 5.x only
Method
Declaration
virtual const char* getUrlPath();
Purpose
Get the path from the URL in the HTTP request line. For example, if the URL is
//foo/bar/baz.htm, the path is //foo/bar.
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::getUrlResource()
RV 5.x only
Method
Declaration
virtual const char* getUrlResource();
Purpose
Get the path from the URL in the HTTP request line. For example, if the URL is
//foo/bar/baz.htm, the resource is baz.htm.
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::getHttpMethod()
RV 5.x only
Method
Declaration
virtual const char* getHttpMethod();
Purpose
Get the HTTP method from the request line.
Parameters
Returns a pointer to either GET or POST or NULL. Do not modify or delete this string.
TAWrvRequest::getHttpUri()
RV 5.x only
Method
Declaration
virtual const char* getHttpUri();
Purpose
Get the HTTP URI from the request line. For example /foo/bar/baz.htm
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::getHttpVersion()
RV 5.x only
Method
Declaration
virtual const char* getHttpVersion();
Purpose
Get the HTTP version string from the request line. For example: HTTP/1.0
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::getHttpRequestEntityBody()
RV 5.x only
Method
Declaration
virtual const char* getHttpRequestEntityBody();
Purpose
Get the HTTP entity body from the request. This is where the POST data is.
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::getUrlParameter()
RV 5.x only
Method
Declaration
virtual const char* getUrlParameter(const char* name);
Purpose
Gets the value of a parameter in the URL query string by name. The lookup is case
sensitive.
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::getHttpRequestHeader()
RV 5.x only
Method
Declaration
virtual const char* getHttpRequestHeader(const char* name);
Purpose
Gets the value of a request header by name. The lookup is case insensitive.
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::setHttpReplyEntityBody()
RV 5.x only
Method
Declaration
virtual void setHttpReplyEntityBody(const char* body);
virtual void setHttpReplyEntityBody(const char* body, unsigned long
bodyLen);
Purpose
Set the HTTP reply entity body. This is where the reply data gets set. The first form is used
to return a string. The second form is used to return binary data such as images.
Parameters
Name Description
TAWrvRequest::setHttpReplyHeader()
RV 5.x only
Method
Declaration
virtual void setHttpReplyHeader(const char*name, const char* value);
virtual void setHttpReplyHeader(const char* name, int value);
Purpose
Set a HTTP reply header to either a string or an integer.
Parameter
Name Description
bTAWrvRequest::setHttpStatusCode()
RV 5.x only
Method
Declaration
virtual void setHttpStatusCode(int code);
Purpose
Set a HTTP reply status code.
Parameters
Name Description
TAWrvRequest::getRvdqSenderName()
RV 5.x only
Method
Declaration
virtual const char* getRvdqSenderName();
Purpose
Get the name of the RVDQ sender. This is only relevant to RVDQ-based service instances.
Parameters
Returns a pointer to the string or NULL. Do not modify or delete this string.
TAWrvRequest::getRvdqSequenceNumber()
RV 5.x only
Method
Declaration
rvcm_Seq getRvdqSequenceNumber();
Purpose
Get the RVDQ sequence number of this request message. This is only relevant to
RVDQ-based service instances.
Parameters
Returns the sequence number.
TAWrvRequest::reply()
RV 5.x only
Method
Declaration
rv_Boolean reply();
Purpose
These methods marshall parameters from the TAWrvRequest into an RvMsg and send
them back to the requesting servlet. The first form assumes that all reply headers and data
have been stored using TAWrvRequest set methods. The remaining two forms are for
convenience. The second form is for sending binary data, and the third form is for sending
strings.
Parameters
Name Description
entityBody The desired reply entity body. Either a string or buffer of binary
data, depending on whether entityBodyLen is specified.
TAWrvRequest::getProtocolVersion()
RV 5.x only
Method
Declaration
int getProtocolVersion();
Purpose
Get the TIB/Adapter for Web version number.
Parameters
Returns the version number.
TAWrvRequest::setHttpReasonPhrase()
RV 5.x only
Method
Declaration
virtual void setHttpReasonPhrase(const char* phrase);
Purpose
Set a HTTP reply reason phrase; for example, OK.
Parameters
Name Description
phrase The descriptive phrase that accompanies the HTTP reply status
code.
TAWrvRequest::isValid()
RV 5.x only
Method
Declaration
rv_Boolean isValid();
Purpose
Tests object validity. Useful for detecting failures during a TAWrvRequest constructor.
Parameters
None.
Example
TAWrvRequest* pRequest
= new TAWrvRequest(subject, replySender, rDatum, invoker);
if(!pRequest->isValid())
{
pImpl->_errorMsg = “Bad datum”;
#if DEBUG
printf(“TAWrvServiceRequestCallback::onData %s\n”, pImpl->_errorMsg);
rDatum.print();
printf(“\n”);
#endif
}
else
pImpl->_rTAWrvService.onRequest(pRequest);
delete pRequest;
TAWrvRequest::getUrlParameters()
RV 5.x only
Method
Declaration
const RvMsg& getUrlParameters();
Purpose
Return the URL query parameters as an RvMsg.
Parameters
None.
TAWrvRequest::getHttpRequestHeaders()
RV 5.x only
Method
Declaration
const RvMsg& getHttpRequestHeaders();
Purpose
Return the HTTP request headers as an RvMsg.
Parameters
None.
Four example C++ programs are provided with TIB/Adapter for Web:
simplesvc.cc. This is a glorified Hello World program that allows you to specify the
subject the service will listen for requests on, and the string it will return.
filesvc.cc. This shows how to transmit string or binary data and set HTTP reply
headers.
worldhello.cc. This is a service pool example. Depending on the command line
argument given, the service will return a language-specific greeting. If you run
multiple instances of this service, each replying in a different language, requests will
be randomly distributed to worker services by the RVDQ scheduler, and you will see
greetings in different languages if you make multiple requests.
hellogoodbye.cc. This is another service pool example. This shows how an initial
request can be directed to a worker service by the RVDQ scheduler, and how the
direct request subject is used to bypass the RVDQ scheduler for subsequent requests
from the same client. In addition to returning a language-specific greeting like
worldhello.cc, this service also returns a hyperlink that contains the direct request
subject. When this hyperlink is clicked, the client communicates directly with the
service instance instance that provided the greeting page. This idiom is useful when
you need to maintain a session between client and service, as well as between fault
tolerant and load balanced services.
simplesvc.cc
RV 5.x only
Note the following:
Code Listing
#include "rv5/TAWrv.h"
#include "stdlib.h"
#include "string.h"
void
SimpleService::onRequest(TAWrvRequest* pRequest)
{
pRequest->reply(_replyString);
}
if(argc < 3)
{
printf("usage: %s <listen subject> <reply string>\n", argv[0]);
exit(-1);
}
char* subject = argv[1];
char* replyString = argv[2];
Example Usage
Start the program from the command line. For example:
> simplesvc my.test.simplesvc hello
filesvc.cc
RV 5.x only
Note the following:
Code Listing
#include "rv5/TAWrv.h"
#include "stdlib.h"
#include "string.h"
void
FileService::onRequest(TAWrvRequest* pRequest)
{
pRequest->setHttpReplyHeader("content-type", _contentType);
if(_dataRvmsgType == RVMSG_STRING)
{
pRequest->reply(_data);
}
FileService::~FileService()
{
if(_data)free(_data);
}
Example Usage
Start the program from the command line. For example, if /foo/bar.gif is a gif image
file, you can run:
> filesvc my.test.filesvc /foo/bar.gif image/gif
worldhello.cc
RV 5.x only
Note the following:
Code Listing
#include "rv5/TAWrv.h"
#include "rvcmqcpp.h"
#include "rvevm.h"
#include "stdlib.h"
#include "stdio.h"
#include "unistd.h"
#define RVDQ_SCHEDULER_WEIGHT 1
#define RVDQ_SCHEDULER_HEARTBEAT 1000 // milliseconds
#define RVDQ_SCHEDULER_ACTIVATION 3000 // milliseconds
#define RVDQ_LISTEN_SUBJECT "taw.worldhello"
#define RVDQ_SERVICE_POOL "worldhello"
WorldHelloService::WorldHelloService(RvCmqSession *pRvCmqSession,
const char* requestSubject,
int iGreetingNumber)
: TAWrvService(pRvCmqSession, requestSubject)
{
_iGreetingNumber = iGreetingNumber % NUMGREETINGS;
}
void
WorldHelloService::onRequest(TAWrvRequest* request)
{
char buf[512];
sprintf(buf, "<html><body><h2>%s</body></html>",
greetings[_iGreetingNumber]);
request->setHttpReplyHeader("content-type","text/html");
request->reply(buf);
};
rv_Session s;
if( argc < 2 )
{
printf("usage: %s <language index>\n", argv[0]);
exit(-1);
}
int gNum = atoi(argv[1]);
if( rvevm_Make(&context) != RVEVM_OK)
{
printf("rvevm_Make() failed.\n");
exit(-1);
}
char* rvService = getenv("RVSERVICE");
char* rvNetwork = getenv("RVNETWORK");
char* rvDaemon = getenv("RVDAEMON");
rv_Error err = rv_InitSession(&s, context, rvService, rvNetwork,
rvDaemon);
if(err != RV_OK)
{
printf("rv_InitSession() failed.\n");
exit(-1);
}
RvCmqSession* pRvCmqSession
= new RvCmqSession(s,
RVDQ_SERVICE_POOL,
RVDQ_SCHEDULER_WEIGHT,
RVDQ_SCHEDULER_HEARTBEAT,
RVDQ_SCHEDULER_ACTIVATION );
if(((RvCmqSession*)pRvCmqSession)->status() != RVCM_OK)
{
printf("RvSession constructor failed.\n");
exit(-1);
}
WorldHelloService *pWorldHelloService
= new WorldHelloService(pRvCmqSession, RVDQ_LISTEN_SUBJECT, gNum);
if(!pWorldHelloService->isValid())
{
printf("TAWrvService constructor failed. %s\n",
pWorldHelloService->getErrorMsg());
exit(-1);
}
printf("listening to %s for requests\n", RVDQ_LISTEN_SUBJECT);
if(! pWorldHelloService->enableRequests() )
printf("Unable to enable request processing: %s\n",
pWorldHelloService->getErrorMsg());
else
rv_MainLoop(s);
}
Example Usage
Start multiple instances of this program from the command line. For example:
> worldhello 0 &
> worldhello 1 &
> worldhello 2 &
This runs three instances in the background. The listen subject, taw.worldhello is
hardcoded into the program. From your browser issue:
http://<your web server>/servlet/TAW?subject=taw.worldhello
Each time you do so, you will see either Hello, Bonjour or Konnichiwa in your browser.
hellogoodbye.cc
RV 5.x only
Note the following:
Code Listing
#include "rv5/TAWrv.h"
#include "rvcmqcpp.h"
#include "rvevm.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#define RVDQ_SCHEDULER_WEIGHT 1
#define RVDQ_SCHEDULER_HEARTBEAT 1000 // milliseconds
#define RVDQ_SCHEDULER_ACTIVATION 3000 // milliseconds
#define RVDQ_LISTEN_SUBJECT "taw.hellogoodbye"
#define RVDQ_SERVICE_POOL "hellogoodbye"
#define NUMGREETINGS 5
HelloGoodbyeService::HelloGoodbyeService(RvCmqSession *pRvCmqSession,
const char* requestSubject,
int iGreetingNumber)
: TAWrvService(pRvCmqSession, requestSubject)
{
// Determine which greeting to return
_iGreetingNumber = iGreetingNumber % NUMGREETINGS;
// Compute a direct request subject based on host name and process id
char buf[512];
char nameBuf[256];
strcpy(nameBuf,"unknown");
gethostname(nameBuf, sizeof(nameBuf));
sprintf(buf, "%s.%s.%d", getRequestSubject(), nameBuf, getpid());
setDirectRequestSubject(buf);
}
printf("rv_InitSession() failed.\n");
exit(-1);
}
RvCmqSession* pRvCmqSession
= new RvCmqSession(s,
RVDQ_SERVICE_POOL,
RVDQ_SCHEDULER_WEIGHT,
RVDQ_SCHEDULER_HEARTBEAT,
RVDQ_SCHEDULER_ACTIVATION );
if(((RvCmqSession*)pRvCmqSession)->status() != RVCM_OK)
{
printf("RvSession constructor failed.\n");
exit(-1);
}
HelloGoodbyeService *pHelloGoodbyeService
= new HelloGoodbyeService(pRvCmqSession, RVDQ_LISTEN_SUBJECT, gNum);
if(!pHelloGoodbyeService->isValid())
{
printf("TAWrvService constructor failed. %s\n",
pHelloGoodbyeService->getErrorMsg());
exit(-1);
}
printf("listening to %s for requests\n", RVDQ_LISTEN_SUBJECT);
if(! pHelloGoodbyeService->enableRequests() )
printf("Unable to enable request processing: %s\n",
pHelloGoodbyeService->getErrorMsg());
else
rv_MainLoop(s);
}
Example Usage
Start multiple instances of this program from the command line. For example:
hellogoodbye 0 &
hellogoodbye 1 &
hellogoodbye 2 &
This runs three instances in the background. The listen subject, taw.hellogoodbye is
hardcoded into the program. From your browser issue:
http://<your web server>/servlet/TAW?subject=taw.hellogoodbye
Each time you do so, you will see either Hello, Bonjour or Konnichiwa in your browser,
just as you did with worldhello.
Now, if you click “Now say goodbye.”, the URL behind this link causes a request to be
made using the direct request subject. The same service instance that responded with the
greeting will now say goodbye in the same language.
This appendix describes the Java API for TIB/Rendezvous 5.x. Use this API to write
TIB/Adapter for Web service instances when linking to TIB/Rendezvous 5.x. With this
API you can also create a service pool and use TIB/Rendezvous version 5.x distributed
queues to load balance requests to service pool members.
Topics
Overview
Your TIB/Adapter for Web service instances must perform the following basic steps:
1. Make sure that taweb.jar and rvjpro.jar are in your CLASSPATH.
2. Create a subclass of TAWrvService that implements TAWrvService::onRequest().
Inside onRequest(), arrange for one of the TAWrvRequest::reply() methods to
return data to the servlet.
3. In your subclass main program, instantiate your TAWrvService subclass, and then call
its enableRequests() method to begin listening for requests.
The example programs, simplesvc and filesvc illustrate this basic structure. They also
show how to handle non-text data and manipulate HTTP reply headers. See Java Example
Service Instances for TIB/Rendezvous 5.x on page 298 for details.
Service Pools
In some applications, the request rate can exceed the capacity of a single service instance.
A service pool is a fault-tolerant and load-balanced collection of services.
TIB/Rendezvous Distributed Queues (RVDQ) ensure that a request is delivered to only
one pool member. The TAW Java API makes it very convenient to set up service pools.
For more information on setting up service pools, see Setting up RVDQ Service Pools on
page 324.
There are two classes that you need to know to use the Java API.
com.tibco.portal.gw.web.api.rv5.TAWrvService
com.tibco.portal.gw.web.api.rv5.TAWrvRequest
The interface for these classes are described in this section. Note that you must create your
own subclass of TAWrvService. The onRequest() or onDirectRequest() methods of
this subclass will receive TAWrvRequest objects which contain all of the HTTP
information about the request as well as any data.
com.tibco.portal.gw.web.api.rv5.TAWrvService
RV 5.x only
Class
Purpose
TAWrvService is an abstract base class that all TAW service instances must subclass. This
subclass must implement the onRequest() method which is invoked whenever a request
is received from TIB/Rendezvous.
Remarks
The constructors provide the ability to:
Create a new standard, non-load-balanced service instance using an RvSession that
will be created for you.
Create a new service instance using an existing TIB/Rendezvous distributed queues
session.
Create a new service instance using an existing reliable TIB/Rendezvous session.
Member Summary
TAWrvService()
RV 5.x only
Constructor
Declaration
TAWrvService();
TAWrvService(RvSession rvSession,
String requestSubject) throws RvException;
TAWrvService(RvCmqSession rvCmqsession,
String requestSubject) throws RvException;
TAWrvService(RvCmqSession ,
String requestSubject,
String directRequestSubject) throws RvException;
Purpose
Provide constructors for the TAWrvService class.
TAWrvService() creates a new service instance instance. A reliable TIB/Rendezvous
session is created for use by this instance. The system properties RVSERVICE,
RVNETWORK, and RVDAEMON, may be used to tailor this session. An RvException is
thrown when the TIB/Rendezvous session initialization fails.
TAWrvService(RvSession) creates a new service instance instance using an existing
reliable TIB/Rendezvous session.
TAWrvService(RvSession, String) creates a new service instance instance using an
existing reliable TIB/Rendezvous session, and the specified request subject.
TAWrvService(String) creates a new service instance instance using the specified
request subject. A reliable TIB/Rendezvous session is created for use by this session.
TAWrvService(RvCmqSession) creates a new service instance instance using an existing
TIB/Rendezvous distributed queues session. A reliable TIB/Rendezvous session will be
created for use by this instance.
TAWrvService(RvCmqSession, String) creates a new service instance instance using an
existing TIB/Rendezvous distributed queues session, and the specified request subject.
TAWrvService(RvCmqSession, String, String) create a new service instance instance
using an existing TIB/Rendezvous distributed queues session, and the specified request
and direct request subjects.
Remarks
All applications must provide a subclass of TAWrvService that implements the
onRequest method.
Subjects need not be specified here, but must be set prior to enabling the service.
Parameters
Name Description
Example
public class SimpleSvc extends TAWrvService
{
public static void main(String argv[])
{
try
{ ...
{
Tibrv.open(Tibrv.IMPL_NATIVE);
SimpleSvc svc = new SimpleSvc();
[truncated...]
Errors
An error will throw an exception:
try { ...
} catch(Exception ...)
TAWrvService.onRequest()
RV 5.x only
Method
Declaration
public abstract void onRequest(TAWrvRequest request);
Purpose
All applications must provide a subclass of TAWrvService that implements the
onRequest() method. This method is called when a request is received from
TIB/Rendezvous on the primary request subject.
Parameters
Name Description
TAWrvService.onDirectRequest()
RV 5.x only
Method
Declaration
public void onDirectRequest(TAWrvRequest request);
Purpose
This method is only relevant to RVDQ-based service instances. This method is called
when a request is received on the direct request subject. Requests to direct request
subjects are not intercepted by the RVDQ scheduler. The default implementation merely
invokes the onRequest() method.
Parameters
Name Description
TAWrvService.setRequestSubject()
RV 5.x only
Method
Declaration
public void setRequestSubject(String subject);
Purpose
This subject is used to specify which subject the service will listen for either normal,
reliable requests, or for RVDQ-based requests. This subject is used by both RVDQ-based
pooled services, or by singleton applications.
Parameters
Name Description
subject Rendezvous subject name that the service will use to listen for
requests.
TAWrvService.setDirectRequestSubject()
RV 5.x only
Method
Declaration
public void setDirectRequestSubject(String subject);
Purpose
Set the subject name used to listen for requests directed at a specific member of an
RVDQ-based service pool. This subject is not used by RvSession-based services at all.
RVDQ-based applications can use this subject to get requests without the intervention of
the RVDQ scheduler.
Parameters
Name Description
subject Rendezvous subject name that the service will use to listen for
direct requests.
TAWrvService.getDirectRequestSubject()
RV 5.x only
Method
Declaration
public String getDirectRequestSubject();
Purpose
Get the subject name used to listen for requests directed at a specific member of an
RVDQ-based service pool. This subject is not used by RvSession-based services at all.
RVDQ-based applications can use this subject to get requests without the intervention of
the RVDQ scheduler. This is a secondary subject used by RVDQ-based services to listen
for requests that bypass RVDQ load-balancing.
Parameters
Returns a pointer to the subject name string or NULL.
TAWrvService.getRequestSubject()
RV 5.x only
Method
Declaration
public String getRequestSubject();
Purpose
Get the primary subject name used to listen for requests. This subject is used by both
RVDQ-based pooled services, or by singleton applications.
Parameters
Returns the subject used for reliable or RVDQ-based requests.
TAWrvService.enableRequests()
RV 5.x only
Method
Declaration
public void enableRequests() throws TAWException;
Purpose
Before the service will start receiving requests through its onRequest method, the
enableRequests method must be invoked. This sets up the necessary TIB/Rendezvous
listeners.
Parameters
None.
Remarks
Prior to invoking enableRequest(), you must have set the subjects that your service will
accept requests on. You can do this in the constructor, or use setRequestSubject() and
setDirectRequestSubject(). This method creates RvListeners that remain valid until
the disableRequests() method is invoked.
Note that an exception is thrown when either no requestSubject has been set, or if a
TIB/Rendezvous listener cannot be created.
TAWrvService.disableRequests()
RV 5.x only
Method
Declaration
public void disableRequests();
Purpose
This method allows the service to suspend request processing. This method causes the
service to stop listening for requests.
Remarks
This method destroys the RvListeners created in enableRequests().
Parameters
None.
TAWrvService.isEnabled()
RV 5.x only
Method
Declaration
public boolean isEnabled();
Purpose
Whether the service is currently listening for requests may be determined by using this
method.
Parameters
Returns RV_TRUE if the service is currently listening for requests, RV_FALSE otherwise.
TAWrvService.getRvSession()
RV 5.x only
Method
Declaration
public RvSession getRvSession();
Purpose
Get the reliable TIB/Rendezvous session handle in use.
Parameters
Returns the RvSession object in use.
TAWrvService.getRvCmqSession()
RV 5.x only
Method
Declaration
public RvSession getRvCmqSession();
Purpose
Get the RVDQ TIB/Rendezvous session handle in use.
Parameters
Returns the RvCmqSession object in use.
com.tibco.portal.gw.web.api.rv5.TAWrvRequest
RV 5.x only
Class
Purpose
TAWrvRequest objects are manufactured by the TIB/Adapter for Web API when requests
are received. This class encapsulates an HTTP request from the time it is delivered to your
service instance, to after your reply has been transmitted. Its interface consists primarily
of accessors for HTTP protocol information, including the data payload. The reply
method is used to send data back to the browser or other HTTP client.
These objects are created and destroyed by TAW, and are made available to you through
the TAWrvService member callback functions onRequest and onDirectRequest.
Member Summary
TAWrvRequest.getReplySubject()
RV 5.x only
Method
Declaration
public String getReplySubject();
Purpose
This method returns the subject that the TIB/Adapter for Web servlet is using to listen for
the reply.
Parameters
Returns the subject name string.
TAWrvRequest.getUrlPath()
RV 5.x only
Method
Declaration
public String getUrlPath() throws TAWException;
Purpose
Get the path from the URL in the HTTP request line. For example, if the URL is
//foo/bar/baz.htm, the path is //foo/bar.
Parameters
Returns the path string.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getUrlResource()
RV 5.x only
Method
Declaration
public String getUrlResource() throws TAWException;
Purpose
Get the target resource string from the URL in the HTTP request line. For example, if the
URL is //foo/bar/baz.htm, the resource is baz.htm.
Parameters
Returns the resource string.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getHttpMethod()
RV 5.x only
Method
Declaration
public String getHttpMethod() throws TAWException;
Purpose
Get the HTTP method from the request line.
Parameters
Returns the HTTP method string.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getHttpUri()
RV 5.x only
Method
Declaration
public String getHttpUri() throws TAWException;
Purpose
Get the HTTP URI from the request line. For example /foo/bar/baz.htm
Parameters
Returns the HTTP URI string.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getHttpVersion()
RV 5.x only
Method
Declaration
public String getHttpVersion() throws TAWException;
Purpose
Get the HTTP version string from the request line. For example: HTTP/1.0
Parameters
Returns the HTTP version string.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getHttpRequestEntityBody()
RV 5.x only
Method
Declaration
public String getHttpRequestEntityBody() throws TAWException;
Purpose
Get the HTTP entity body (i.e. POST data) from the request.
Parameters
Returns the HTTP data string.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getUrlParameter()
RV 5.x only
Method
Declaration
public String getUrlParameter(String name) throws TAWException;
Purpose
Gets the value of an individual query parameter from the URL on the request line. The
lookup is case sensitive.
Parameters
Name Description
Returns a string holding the value associated with parameter name or NULL.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getUrlParameters()
RV 5.x only
Method
Declaration
public RvMsg getUrlParameters() throws TAWException;
Purpose
This method gets all query parameters from the URL on the request line.
Parameters
Returns an RvMsg containing one field for each parameter or NULL.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getHttpRequestHeader()
RV 5.x only
Method
Declaration
public String getHttpRequestHeader(String name) throws TAWException;
Purpose
Gets the value of a request header by name. The lookup is case insensitive.
Parameters
Name Description
Returns a string holding the header value associated with header name or NULL.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.getHttpRequestHeaders()
RV 5.x only
Method
Declaration
public RvMsg getHttpRequestHeaders() throws TAWException;
Purpose
Gets all of the HTTP request headers.
Parameters
Returns an RvMsg containing one field for each header or NULL.
Remarks
An exception is thrown when the value of the corresponding RvMsg field is not a string.
TAWrvRequest.setHttpReplyEntityBody()
RV 5.x only
Method
Declaration
public void setHttpReplyEntityBody(String body);
public void setHttpReplyEntityBody(byte body[]);
Purpose
Set the HTTP reply entity body. This is how you associate reply data with the request. The
first form is used to specify the reply as a string. The second form is used to return binary
data such as images.
Parameters
Name Description
TAWrvRequest.setHttpReplyHeader()
RV 5.x only
Method
Declaration
public void setHttpReplyHeader(String name, String value);
public void setHttpReplyHeader(String name, int value);
Purpose
Set a HTTP reply header to either a string or an integer. Any pre-existing value for that
header is replaced.
Parameters
Name Description
TAWrvRequest.setHttpStatusCode()
RV 5.x only
Method
Declaration
public void setHttpStatusCode(int code);
Purpose
Set an HTTP reply status code.
Parameters
Name Description
TAWrvRequest.getRvdqSenderName()
RV 5.x only
Method
Declaration
public String getRvdqSenderName();
Purpose
Get the name of the RVDQ sender. This is only relevant to RVDQ-based service instances.
Parameters
Returns the string holding the RVDQ sender name.
TAWrvRequest.getRvdqSequenceNumber()
RV 5.x only
Method
Declaration
public int getRvdqSequenceNumber();
Purpose
Get the RVDQ sequence number of this request message. This is only relevant to
RVDQ-based service instances.
Parameters
Returns the sequence number.
TAWrvRequest.reply()
RV 5.x only
Method
Declaration
public void reply() throws TAWException
Purpose
These methods are used to send a reply back to the HTTP client through the web browser.
The simplest form reply() is used to send a reply back to the HTTP client through the
web browser when all HTTP reply information, including reply data, status code, and
reason phrase have already been set via TAWrvRequest accessor methods. If no status
code or reason phrase has been set, “200” and “OK” respectively will be used.
The remaining forms are for convenience, and allow you to set string or binary data,
status code, and reason phrase in one call.
reply(byte entityBody[]) sends a reply containing binary data back to the HTTP
client through the web browser.
reply(byte entityBody[], int statusCode) sends a reply containing binary data
and an HTTP status code back to the HTTP client through the web browser.
reply(byte entityBody[], int statusCode, string reasonPhrase) sends a reply
containing binary data, an HTTP status code, and reason phrase back to the HTTP client
through the web browser.
reply(String entityBody) sends a reply containing string data back to the HTTP
client through the web browser.
reply(String entityBody, int statusCode) sends a reply containing string data and
an HTTP status code back to the HTTP client through the web browser.
reply(String entityBody[], int statusCode, String reasonPhrase) sends a
reply containing string data, an HTTP status code, and reason phrase back to the HTTP
client through the web browser.
Parameters
Name Description
Remarks
An TAWException is thrown when there is a TIB/Rendezvous error during the
transmission of the reply.
TAWrvRequest.getProtocolVersion()
RV 5.x only
Method
Declaration
public int getProtocolVersion();
Purpose
Get the TIB/Adapter for Web version number.
Parameters
Returns the TIB/Adapter for Web version number.
TAWrvRequest.setHttpReasonPhrase()
RV 5.x only
Method
Declaration
public void setHttpReasonPhrase(String phrase);
Purpose
This method sets the reply HTTP reason phrase that should accompany the status code.
For example, OK.
Parameters
Name Description
phrase descriptive phrase that accompanies the HTTP reply status code.
Four example Java programs are provided with TIB/Adapter for Web.
SimpleSvc. This is a glorified "Hello World!" program that allows you to specify the
subject the service will listen for requests on, and the string it will return.
FileSvc. This shows how to transmit string or binary data and set HTTP reply headers.
WorldHello. This is a service pool example. Depending on the command line argument
given, the service will return a language-specific greeting. If you run multiple instances of
this service, each replying in a different language, requests will be randomly distributed
to worker services by the RVDQ scheduler, and you will see greetings in different
languages if you make multiple requests.
HelloGoodbye. This is another service pool example. This shows how an initial request
can be directed to a worker service by the RVDQ scheduler, and how the direct request
subject is used to bypass the RVDQ scheduler for subsequent requests from the same
client. In addition to returning a language-specific greeting like worldhello, this service
also returns a hyperlink that contains the direct request subject. When this hyperlink is
clicked on, the client communicates directly with the service instance instance that
provide the greeting page.
SimpleSvc
RV 5.x only
Note the following:
All service instances must subclass TAWrvService and implement the abstract request
callback member function onRequest.
A TAWrvRequest object is created by TAW when a request is received and is delivered
to an application through the onRequest method. The reply member of TAWrvRequest
is used to transmit the reply string to the client.
In main, a SimpleSvc instance is first created. Then its request subject, and the string
to provide in the reply are set. Finally, requests are enabled.
TAWrvRequest object contain an invisible “return address” that is used by the reply
method to return data to the client through the servlet.
Code Listing
import com.tibco.portal.gw.web.api.rv5.*;
import COM.TIBCO.rv.*;
{
try
{
request.reply(replyString);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
Example Usage
Start the program from the command line. For example:
java SimpleSvc my.test.simplesvc hello
FileSvc
RV 5.x only
Note the following:
All service instances must subclass TAWrvService and implement the abstract request
callback member function onRequest.
A TAWrvRequest object is created by TAW when a request is received and is delivered
to an application through the onRequest method. The reply member of TAWrvRequest
is used to transmit the reply string to the client. An HTTP “content-type” reply
header is set from the command-line-specified value which should be chosen to reflect
the type of file. Next, the appropriate form of reply is used to transmit the file contents
back to the client.
In main, a SimpleSvc instance is created. The desired request subject and content type
are set from command line parameters. The specified file is loaded into a buffer, and if
it is either a .gif or .jpg file, the file is considered a binary file. Finally, requests are
enabled.
When a request is received, the contents of the file are returned to the client using the
appropriate form of reply() for the type of file.
Code Listing
import java.io.*;
import com.tibco.portal.gw.web.api.rv5.*;
import COM.TIBCO.rv.*;
Example Usage
Start the program from the command line. For example: if /foo/bar.gif is a gif image
file, you can run:
> java FileSvc my.test.filesvc /foo/bar.gif image/gif
WorldHello
RV 5.x only
Note the following:
All service instances must subclass TAWrvService and implement the abstract request
callback member function onRequest.
There are no TAWrvService constructors that will build a RVDQ session for you, so
you must build one yourself.
These parameters are used to control the service pools fault-tolerant behavior, as well
as specify the request subject.
Create an instance of WorldHello using the RVDQ session just created. Setup reply
data hash table and finally enable requests.
When a request is received, the onRequest method looks up the appropriate greeting
in the hash table and invokes request's reply method to send it back to the client.
Code Listing
import java.util.*;
import com.tibco.portal.gw.web.api.rv5.*;
import COM.TIBCO.rv.*;
rvdqSchedulerHeartbeat,
rvdqSchedulerActivation);
WorldHello svc
= new WorldHello(session, rvdqListenSubject);
svc.language = argv[0];
svc.greetings = new Hashtable();
svc.greetings.put("english", "Hello");
svc.greetings.put("french", "Bon jour");
svc.greetings.put("japanese", "Konnichiwa");
svc.enableRequests();
System.out.println("Listening on: "+rvdqListenSubject);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
Example Usage
Start multiple instances of this program from the command line. For example:
This runs three instances in the background. The listen subject, taw.worldhello is
hardcoded into the program. From your browser issue:
http://<your web server>/servlet/TAW?subject=taw.WorldHello
Each time you do so, you will see either Hello, Bonjour or Konnichiwa in your browser.
HelloGoodbye
RV 5.x only
Note the following:
All service instances must subclass TAWrvService and implement the abstract
request callback member function onRequest.
There are no TAWrvService constructors that will build a RVDQ session for you, so
you must build one yourself.
These parameters are used to control the service pools fault-tolerant behavior, as well
as specify the request subject.
Create an instance of WorldHello using the RVDQ session just created.
Construct a unique direct request subject by concatenating the identifier specified on
the command line with the request subject and provide it to the service instance. Setup
the reply hash tables and finally enable requests.
Initial requests from a client are delivered to the service through the onRequest
method. This method builds an HTML page that consists of a hyperlink that displays
as hello or foreign language equivalent. The URL in this link embeds the direct
request subject so that when the link is followed, a request will be sent to the service's
direct request subject. This page is then returned to the client.
The onDirectRequest method will never be invoked on the initial client request. It is
only invoked after the service has returned the hello page described above, and after
the user has clicked on the link. In response, the same language that was used to say
hello will be used to prepare a goodbye page.
Code Listing
import java.util.*;
import com.tibco.portal.gw.web.api.rv5.*;
import COM.TIBCO.rv.*;
if(argv.length != 2)
{
System.out.println("usage: java HelloGoodbye <language> <unique
id>");
System.out.println("language = english, french, or japanese");
}
else
{
RvCmqSession session
= new RvCmqSession(System.getProperty("RVSERVICE"),
System.getProperty("RVNETWORK"),
System.getProperty("RVDAEMON"),
rvdqServicePool,
rvdqSchedulerWeight,
rvdqSchedulerHeartbeat,
rvdqSchedulerActivation);
HelloGoodbye svc
= new HelloGoodbye(session, rvdqListenSubject);
// Concatenate unique id to request subject to form the direct
// request subject
String s = rvdqListenSubject + "." + argv[1];
svc.setDirectRequestSubject(s);
svc.language = argv[0];
svc.hellos = new Hashtable();
svc.hellos.put("english", "Hello");
svc.hellos.put("french", "Bon jour");
svc.hellos.put("japanese", "Konnichiwa");
svc.goodbyes = new Hashtable();
svc.goodbyes.put("english", "Goodbye");
svc.goodbyes.put("french", "Au revoir");
svc.goodbyes.put("japanese", "Sayonara");
svc.enableRequests();
System.out.println("Listening on: "+rvdqListenSubject);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
Example Usage
Start multiple instances of this program from the command line. For example:
> java hellogoodbye english 0 &
> java hellogoodbye french 1 &
> java hellogoodbye japanese 2 &
This runs three instances in the background. The listen subject, taw.hellogoodbye is
hardcoded into the program. From your browser issue:
http://<your web server>/servlet/TAW?subject=taw.hellogoodbye
Each time you do so, you will see either Hello, Bonjour or Konnichiwa in your browser,
depending upon which service handles your request.
If you now click on this link, a request will be sent back to the same service using its direct
request subject. The service will respond with goodbye in the same language it used
before. The last numeric argument is used to make a unique direct request subject.
TIB/Rendezvous messages are exchanged between the TIB/Adapter for Web servlet and
your external service instance to complete each client request. This appendix describes
how the TibrvMsg exchange works, and gives the detailed request and reply message
formats. You can use this information to write service instances on platforms that are
supported by TIB/Rendezvous, but do not yet have a corresponding TAW API.
This section also explains how to use the TAW API for TIB/Rendezvous 6.x to set up
RVDQ service pools, and how the API supports client/pool member sessions.
Topics
Protocol
Request and reply messages (TibrvMsgs) are exchanged between the TIB/Adapter for
Web servlet and an external service instance to complete each client request. Both request
and reply messages conform to the AE 3.0 wire format.
The actual data content or payload of the HTTP message is carried by the ^data^ wire
format field. HTTP headers, request-line, and status-line are all parsed into appropriate
TibRvMsgs fields. Applications that cannot, or do not wish to use the TIB/Adapter for
Web API, may provide their own custom code to marshall and unmarshall these fields
and transmit the reply message to the TIB/Adapter for Web servlet.
The return address of the servlet that sent the request is not a field in either the request or
reply message. The servlet uses TibrvTransport::sendRequest() to send the request to
your service instance and create an inbox listener to receive your reply. When you receive
a request, your TibrvMsgCallback::onMsg() method is called and given an
TibrvTransport to use to send the reply.
Applications that are AE 3.0 wire format aware, and have no need to inspect or
manipulate HTTP protocol information, need only concern themselves with the
^-delimited AE 3.0 wire format fields. POST data will appear in the request msg ^data^
field, and the ^data^ field of the reply message carries the reply data payload.
In some applications the message traffic can exceed the capacity of a single service
instance. A service pool can handle a large amount of message traffic. A service pool is a
collection of running applications that use Rendezvous Distributed Queues for
load-balancing requests and fault-tolerance.
Each server application in the pool listens to the same request subject, and
TIB/Rendezvous ensures that only one server receives any particular request. At any
point in time, one of the servers in the pool is the scheduler, and the others are workers.
RVDQ takes care of promoting a worker to a scheduler should the scheduler crash or
otherwise become non-responsive. When a request is issued, the scheduler determines
which server to forward the request to based upon RVDQ tuning parameters, as
described in TIB/Rendezvous documentation.
TIB/Rendezvous messages are exchanged between the TIB/Adapter for Web servlet and
your external service instance to complete each client request. This appendix describes
how the RvMsg exchange works, and gives the detailed request and reply message
formats. You can use this information to write service instances on platforms that are
supported by TIB/Rendezvous, but do not yet have a corresponding TAW API.
This section also explains how to use the TAW API for TIB/Rendezvous 5.x to set up
RVDQ service pools, and how the API supports client/pool member sessions.
Topics
Protocol
Request and reply messages (RvMsgs) are exchanged between the TIB/Adapter for Web
servlet and an external service instance to complete each client request. Both request and
reply messages conform to the AE 3.0 wire format.
The actual data content or payload of the HTTP message is carried by the ^data^ wire
format field. HTTP headers, request-line, and status-line are all parsed into appropriate
RvMsg fields. Applications that cannot, or do not wish to use the TIB/Adapter for Web
API, may provide their own custom code to marshall and unmarshall these fields and
transmit the reply message to the TIB/Adapter for Web servlet.
The return address of the servlet that sent the request is not a field in either the request or
reply message. The servlet uses RvSender::sendRequest() to send the request to your
service instance and create an inbox listener to receive your reply. When you receive a
request, your RvDataCallback::onData() method is called and given an RvSender to
use to send the reply.
Applications that are AE 3.0 wire format aware, and have no need to inspect or
manipulate HTTP protocol information, need only concern themselves with the
^-delimited AE 3.0 wire format fields. POST data will appear in the request msg ^data^
field, and the ^data^ field of the reply message carries the reply data payload.
In the following tables, the TAWrvMsgFLD column provides the class member constants in
Java. Use the constants in TAWrvMsg.h found in the include directory and program
accordingly using the TIB/Rendezvous API.
In some applications the message traffic can exceed the capacity of a single service
instance. A service pool can handle a large amount of message traffic. A service pool is a
collection of running applications that use Rendezvous Distributed Queues for
load-balancing requests and fault-tolerance.
Each server application in the pool listens to the same request subject, and
TIB/Rendezvous ensures that only one server receives any particular request. At any
point in time, one of the servers in the pool is the scheduler, and the others are workers.
RVDQ takes care of promoting a worker to a scheduler should the scheduler crash or
otherwise become non-responsive. When a request is issued, the scheduler determines
which server to forward the request to based upon RVDQ tuning parameters, as
described in TIB/Rendezvous documentation.
A C
APSvc C++ RV 6 92 Client, non GUI 41
appendToHeartbeat() 94 Code
APSvc() 93 FileSvc Java RV 5 301
disable() 95 filesvc.cc RV 5 246
enable() 96 filesvc.cc RV 6 109
init() 97 FileSvc.java RV 6 183
onMsg() 98 Compiler support 11
onTimer() 99 Compiling service examples
sendHeartbeat() 100 C++ RV 5 243
start() 101 C++ RV 6 104
startHeartbeating() 102 Java RV 5 298
terminate() 103 Java RV 6 179
APSvc Java RV 6 158 Configuration information
appendToHeartbeat() 159 retrieving through TIB/Hawk 54
disable() 160 Configuration properties
enable() 161 retrieving through TIB/Hawk 55
init() 162 Configuring
run() 163 IIS with JRun 2.3 17
terminate() 164 IIS with JRun 3.0 22
APSvcImpl Java RV 6 165 iPlanet Web Server 30
appendToHeartbeat() 168 service specific defaults 38
APSvcImpl() 167 TAW Servlet JRun 2.3 17
disable() 169 TAW Servlet JRun 3.0 23
enable() 170 TIB/Rendezvous parameters 42
init() 171 Creating
onMsg() 173 sessions within RVDQ RV 5 325
onTimer() 174 sessions within RVDQ RV 6 317
run() 175
sendHeartbeat() 176
startHeartbeating() 177
terminate() 178 D
Auto-Discovery process 48
Debug level
setting from TIB/Hawk 63
E
Examples H
file service C++ RV 6 108
file service Java RV 6 182 HelloGoodbye Java RV 6 187
HelloGoodbye Java RV 5 307 HelloGoodbye service C++ RV 6 116
MultiDispatcher service C++ RV 6 121 hellogoodbye.cc RV 5 254
MultiDispatcher service Java RV 6 190 hellogoodbye.cc RV 6 117
Raw Service Java RV 6 196 HelloGoodbye.java RV 6 188
service list C++ RV 5 243
service list C++ RV 6 67
services list Java RV 5 298
services list Java RV 6 131 I
simple service C++ RV 6 105
simple service Java RV 6 180 Installation
simple service registry C++ RV 6 125 and configuration 43
simple service registry Java RV 6 193 on Unix 13
SimpleSvc Java RV 5 299 on Windows NT 12
WorldHello C++ RV 6 112 prerequisites, Windows NT 12
WorldHello Java RV 5 304 internalError 40
WorldHello Java RV 6 185 Invoking microagent methods 49
F L
Fault tolerance 4 Licenses
for TIB/Rendezvous 10
Load balancing 4
G
getConfig(), TIB/Hawk method 54 M
getConfigProperties, TIB/Hawk method 55
getDebugLevel(), TIB/Hawk method 56 Mapping arbitrary URLs 43
getDebugSubject(), TIB/Hawk method 57 Microagents 52
getServletContext(), TIB/Hawk method 58 multiDispatcher.cc RV 6 122
O T
onUnsolictedMsg(), TIB/Hawk method 61 taw5config.dat 42
Optional software 11 TAWrvException Java RV 6 157
TAWrvRequest C++ RV 5 221
getHttpMethod() 226
getHttpRequestEntityBody() 229
R getHttpRequestHeader() 231
getHttpRequestHeaders() 242
Repository dat file 42 getHttpUri() 227
Request getHttpVersion() 228
and reply RvMsg formats 321 getProtocolVersion() 238
and reply TibrvMsg formats 313 getReplySubject() 223
RVDQ service pool 7 getRvdqSenderName() 235
semantics 3 getRvdqSequenceNumber() 236
service registry pool 7 getUrlParameter() 230
syntax 7 getUrlParameters() 241
TAW service pool 7 getUrlPath() 224
RVDQ getUrlResource() 225
based services 66 isValid() 240
scheduler 68 reply() 237
service pools RV 5 324 setHttpReasonPhrase() 239
service pools RV 6 316 setHttpReplyEntityBody() 232
setHttpReplyHeader() 233
TAWrvRequest C++ RV 6 83
getHttpHeader() 85
S getHttpHeaders() 85
getHttpMethod() 86
serviceNotUPURL 40 getHttpReplyHeader() 87
Session parameters, RV 42 getHttpReplyHeaders() 87
setDebugLevel(), TIB/Hawk method 62 getHttpReplyOpaqueEntityBody() 87
setDebugSubject(), TIB/Hawk method 64 getHttpReplyReasonPhrase() 87
Starting getHttpReplyStatusCode() 87
TIB/Hawk software on Unix 47 getHttpReplyStringEntityBody() 87
TIB/Hawk software on Windows NT 47 getHttpUri() 86
Supported getHttpVersion() 86
operating systems 10 getProtocolVersion() 86
web servers 10 getReplyMsg() 87
Syntax getReplyProtocolVersion() 87
request 7 getUrlParameter() 86
getUrlParameters() 86
getUrlPath() 86