|Oracle® Coherence Client Guide
Part Number E22839-01
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
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.
The following sections are included in this chapter:
A Remote Invocation Service is configured using the
remote-invocation-scheme element in the cache configuration descriptor. Example 13-1 illustrates a sample 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>9099</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
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);
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
Like cached value objects, all
Invocable implementation classes must be correctly registered in the POF context of the C++ application (see "PortableObject (Self-Serialization)") and cluster-side node to which the client is connected. 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" for additional details.