14 Performing Remote Invocations (C++)
This chapter includes the following sections:
- Overview of Performing Remote Invocations (C++)
AnInvocable
can execute any arbitrary action and can use any cluster-side services (cache services, grid services, and so on) necessary to perform their work. - Configuring and Using the Remote Invocation Service
A Remote Invocation Service is configured using theremote-invocation-scheme
element in the cache configuration descriptor. - Registering Invocable Implementation Classes
Like cached value objects, allInvocable
implementation classes must be correctly registered in the POF context of the C++ application and cluster-side node to which the client is connected.
Parent topic: Creating C++ Extend Clients
Overview of Performing Remote Invocations (C++)
Invocable
can execute any arbitrary action and can use any cluster-side services (cache services, grid services, and so on) necessary to perform their work. The Invocable operations can also be stateful, which means that their state is serialized and transmitted to the grid nodes on which the Invocable is run.
Coherence for C++ provides a Remote Invocation Service which allows the execution of Invocables
within the cluster-side JVM to which the client is connected. In Java, Invocables are simply runnable application classes that implement the com.tangosol.net.Invocable
interface. To employ an Invocable
in Coherence for C++, you must deploy a compiled Java implementation of the Invocable
task on the cluster-side node, in addition to providing a C++ implementation of Invocable
: coherence::net::Invocable
. Since execution is server-side (that is, Java), the C++ invocable need only be concerned with state; the methods themselves can be no-operations.
Parent topic: Performing Remote Invocations (C++)
Configuring and Using the Remote Invocation Service
remote-invocation-scheme
element in the cache configuration descriptor.The following example illustrates a remote invocation scheme configuration.
<remote-invocation-scheme> <scheme-name>example-invocation</scheme-name> <service-name>ExtendTcpInvocationService</service-name> <initiator-config> <tcp-initiator> <remote-addresses> <socket-address> <address>localhost</address> <port>7077</port> </socket-address> </remote-addresses> </tcp-initiator> <outgoing-message-handler> <request-timeout>30s</request-timeout> </outgoing-message-handler> </initiator-config> </remote-invocation-scheme>
A reference to a configured Remote Invocation Service can then be obtained by name by using the coherence::net::CacheFactory
class:
InvocationService::Handle hService = hService::getService("ExtendTcpInvocationService");
To execute an agent on the grid node to which the client is connected requires only one line of code:
Map::View hResult = hService->query(myTask::create(), NULL);
The Map
returned from query is keyed by the member on which the query is run. For Extend clients, there is no concept of membership, so the result is keyed by the local member which can be retrieved by calling CacheFactory::getConfigurableCacheFactory()::GetLocalMember()
Parent topic: Performing Remote Invocations (C++)
Registering Invocable Implementation Classes
Invocable
implementation classes must be correctly registered in the POF context of the C++ application and cluster-side node to which the client is connected. See PortableObject (Self-Serialization). As such, a Java implementation of the Invocable
task (a com.tangosol.net.Invocable
implementation) must be created, compiled, and deployed on the cluster-side node. See Registering Custom C++ Types.
Parent topic: Performing Remote Invocations (C++)