Service Agents
42
Member functions of a service binding object which may prove useful include "serviceName()",
"agentIdentity()", "serviceAudience()", "processAddress()" and "serviceLo-
cation()". Of these, "serviceLocation()" returns either "SERVICE_LOCAL"or
"SERVICE_REMOTE", giving an indication if the service is located in the same process or a remote
process. The "processAddress()" member function will return an internal address relating to the
actual process the service is located in.
Although the shorthand "agentIdentity()" member function provides a more readable value, the
"serviceAddress()" member function is also provided and returns the internal address used to
identify the service. Note though that if in a distributed application an intermediary process along the
route to the actual service is restarted, when all processes reconnect, the service address will be differ-
ent where as the process identity and agent identity would be the same. This reflects the fact that it is
still the same service, but the route used to contact the service has now changed as the intemediary
process was restarted.
When subscribing to the service registry as a whole, each notification will also include a group and
status value. When the group is "None", the notification refers to either the availability or withdrawal
of a service. For any other value of group, it indicates that a specific service is joining or leaving that
group. Whether a service has become available or has been withdrawn, or similarly whether a service
has joined or left a group is given by the status value. When the status is "SERVICE_AVAILABLE",
a service has become available or has joined a group as appropriate. When the status value is
"SERVICE_WITHDRAWN" the service has either been withdrawn or has left a group as appropriate.
Note that when the status indicates that a service has become available it doesn’t mean that the service
only just got created. In the case that a service is in a remote process, it may be the case that a service
has existed for some time, but because the local process has only just connected into a distributed ap-
plication it has only just become aware of that fact.
Similarly, when a service is withdrawn, if the service was in a remote process it means the service can
no longer be contacted. This may have occurred because the service itself has been destroyed, the proc-
ess in which the service existed has been destroyed or that an intemediary process involved in the com-
munication path for contacting that process has been destroyed and the remote process is currently no
longer contactable.
By subscribing to the service registry it is possible to receive in real time notitifications regarding the
availability of services as such events happen. If you only wish to find out which services are available
at a particular instant in time, you can use the "serviceAgents()" member function. Note that de-
pending on the number of service agents available, calling this member function repetitively can incur
significant overhead. If possible this member function should be used sparingly and a subscription
against the service registry used instead.