Coherence for .NET provides a Remote Invocation Service which allows execution of single-pass agents (called
IInvocable objects) within the cluster-side JVM to which the client is connected. Agents are simply runnable application classes that implement the
IInvocable interface. Agents 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 agent operations can also be stateful, which means that their state is serialized and transmitted to the grid nodes on which the agent is run.
The following section is included in this chapter:
A Remote Invocation Service is configured using the
<remote-invocation-scheme> element in the cache configuration descriptor. For example:
... <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
IInvocationService service = (IInvocationService) CacheFactory.GetService("ExtendTcpInvocationService");
To execute an agent on the grid node to which the client is connected requires only one line of code:
IDictionary result = service.Query(new MyTask(), null);
The single result of the execution are keyed by the local
Member, which can be retrieved by calling
Note:Like cached value objects, all
IInvocableimplementation classes must be correctly registered in the POF context of the .NET application and cluster-side node to which the client is connected. As such, a Java implementation of the
com.tangosol.net.Invocableimplementation) must be created, compiled, and deployed on the cluster-side node. Note that the actual execution of the task is performed by the Java
Invocableimplementation and not the .NET
See Chapter 17, "Configuration and Usage for .NET Clients" for additional details.