20 Performing Remote Invocations (.NET)

This chapter provides instructions for performing remote invocations on Coherence caches from .NET clients.

The following section is included in this chapter:

20.1 Overview of Performing Remote Invocations

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.

20.2 Configuring and Using the Remote Invocation Service

A Remote Invocation Service is configured using the <remote-invocation-scheme> element in the cache configuration descriptor. For example:

Example 20-1 Configuring a Remote Invocation Service

...
<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 CacheFactory class:

Example 20-2 Obtaining a Reference to a Remote Invocation Service

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:

Example 20-3 Executing an Agent on a Grid Node

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 CacheFactory.ConfigurableCacheFactory.LocalMember.

Note:

Like cached value objects, all IInvocable implementation 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 IInvocable task (a com.tangosol.net.Invocable implementation) must be created, compiled, and deployed on the cluster-side node. Note that the actual execution of the task is performed by the Java Invocable implementation and not the .NET IInvocable implementation.

See Chapter 16, "Configuration and Usage for .NET Clients" for additional details.