beautypg.com

HP Reliable Transaction Router User Manual

Page 74

background image

Application Programming Interfaces

Example 4–5 Creating a Facility with the C++ API

// Use the C++ interface to create an RTR facility
RTRFacilityManager::CreateFacilityWithAllRoles_3()
{
bool bOverallResult = true;
//Create facility manager, abort if creation fails

RTRFacilityManager * pFacilityManager;
pFacilityManager = new RTRFacilityManager;

if ( IsFailure(pFacilityManager != NULL) )

{

return false;

}

// Create the facility

rtr_status_t stsCreateFacility;

stsCreateFacility =

pFacilityManager->CreateFaclity("FaclityWithAllRoles_3",

GetDefaultRouterName(),
GetDefaultFrontendName(),
GetDefaultBackendName(),
true,
false);

//If facility creation is not successful, report it
if ( IsFailure( stsCreateFaciltiy == RTR_STS_OK ) )

{
bOverallResult = false;
OutputStatus( stsCreateFacility);
}

else // Delete a successfully created facility
{
rtr_status_t stsDeleteFacility;

stsDeleteFacility =

pFacilityManager->DeleteFacility("FacilityWithAllRoles_3");

if ( IsFailure( stsDeleteFacility == RTR_STS_OK ) )
{
bOverallResult = false;
OutputStatus) stsDeleteFacility);
}
}

// Clean up and return

delete pFacilityManager;

return bOverallResult;
}

4–20 RTR Interfaces