web analytics

How to Configure COM+ Recycling Parameters Programmatically with the COM+ 1.5 Catalog?

Options

davegate 143 - 921
@2016-01-16 15:15:15

You can configure the recycling parameters programmatically with the COM+ 1.5 Catalog. To configure memory and time-bound recycling, use the RecycleMemoryLimit and RecycleLifetimeLimit named properties of the application's Catalog object. If you want to configure the expiration timeout, you need to use the RecycleExpirationTimeout named property. Here is an example to programmatically method.

//usage: "FirstApp" will be recycled after 250 object activations
//hres = SetRecycleByActivations("FirstApp",250);

HRESULT SetRecycleByActivations(LPCSTR lpcszAppName,DWORD dwActivations)
{
//Verify app name is valid
if(_bstr_t(lpcszAppName) == _bstr_t(""))
{
return E_INVALIDARG;
}
HRESULT hres = S_OK;
ICOMAdminCatalog2* pCatalog = NULL;
hres = ::CoCreateInstance(CLSID_COMAdminCatalog, NULL,CLSCTX_SERVER,
IID_ICOMAdminCatalog2,(void**)&pCatalog);

ICatalogObject* pApplication = NULL;
ICatalogCollection* pApplicationCollection = NULL;
long nCountofApp = 0;
int index = 0;//Index of Application

//Get the application collection
hres = pCatalog->GetCollection(_bstr_t("Applications"),
(IDispatch**)&pApplicationCollection);
pCatalog->Release();

hres = pApplicationCollection->Populate();

hres = pApplicationCollection->get_Count(&nCountofApp);

hres = COMADMIN_E_OBJECT_DOES_NOT_EXIST;
for(index=0; index{
//Get the current application
hres = pApplicationCollection->get_Item
(index,(IDispatch**)&pApplication);

_variant_t varName;

pApplication->get_Name(&varName);
_bstr_t bstrName(varName);

if(bstrName == _bstr_t(lpcszAppName))
{
long ret = 0;
_variant_t varActivationLimit((long)dwActivations);
hres = pApplication->put_Value(_bstr_t("RecycleActivationLimit"),
varActivationLimit);
hres = pApplicationCollection->SaveChanges(&ret);
}
pApplication->Release();
}
pApplicationCollection->Release();
return hres;
}


When you need to configure the call or activation limits programmatically, set the RecycleCallLimit or RecycleActivationLimit properties. The code provides the SetRecycleByActivations helper function, which sets a limit of activations for recycling a specified application.

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com