Retrieve a core service instance ID
You can retrieve a core service instance ID for a component that can be configured to support high availability. Components that cannot be configured to support high availability have only a service instance. The following code sample retrieves a
Dispatcher core service instance ID.
Before you begin: Retrieve the following variables:
- serviceID integer for the service that you want to find
the core service instance ID of
- instanceName string for the name of the core service instance that you want to find the ID for
-
Create an integer to store the core service instance ID.
int coreServiceInstanceID;
-
Invoke findServiceInstancesByService().
boolean includeStatus=false;
boolean includeExtendedData=true;
boolean loadServiceConsumerRelationships=false;
boolean loadServiceProducerRelationships=false;
FindServiceInstancesByServiceResult result=coreWebService.findServiceInstancesByService(serviceID, locale, includeStatus, includeExtendedData, loadServiceConsumerRelationships, loadServiceProducerRelationships);
-
Check the result for errors and handle any errors.
if (result.getFindServiceInstancesByServiceReturnStatus().getCode()!= FindServiceInstancesByServiceReturnStatusEnumType.SUCCESS)
{
// handle any errors
}
- Loop through the result until you find the core service instance that you want to retrieve the ID for.
List<ServiceInstanceType> serviceInstances = result.getServiceInstances();
for (ServiceInstanceType itr:serviceInstances)
{
if (itr instanceof DispatcherCoreServiceInstance)
{
if (itr.getName().equalsIgnoreCase(instanceName))
{
return itr.getServiceId();
}
}
}
Was this information helpful? Send us your comments.