Table of Contents

Deploying an Invocation Grid Project

When an IG worker project is ready to be deployed, it must be built, zipped, and uploaded to host systems that are running the ScaleOut service. The ig start command line utility is used to automate these tasks.

Prerequisites

Procedure

  1. Open a command prompt in the IG project directory. If you are following the example from the Creating an Invocation Grid Project topic, open the prompt in the ShoppingCartIG folder.

  2. Run the following command to build, package and deploy your IG worker project (modifying the connection string with the address of one of your ScaleOut hosts):

    ig start -c "bootstrapGateways=localhost:721"
    
    • The ig start command will not return until your IG worker has been started on all hosts running the ScaleOut service.
    • The specified connection string only needs to contain one host from your grid of ScaleOut services. Once the utility connects to one of the hosts, it will learn about the rest of the cluster members and will deploy your IG worker to all of the servers.
    Tip

    If you will be issuing multiple ig commands, set the SOSS_IG_CONN environment variable to your connection string if you do not want to supply the -c argument every time you run the utility.

    set SOSS_IG_CONN=bootstrapGateways=localhost:721
    
  3. Multiple Invocation Grid workers can run simultaneously on ScaleOut hosts. To see a list of all running IG workers:

    ig status -c "bootstrapGateways=localhost:721"
    
  4. An invocation grid worker can remain running indefinitely. If you need to shut down your Invocation Grid, issue an ig stop command:

    ig stop -c "bootstrapGateways=localhost:721"
    
    • The IG stop command defaults to stopping the IG worker that is associated with the .NET project directory that you are currently working in. If you do not have the project available or simply want to issue the name of an IG to stop from a different folder, use the -n flag to specify the name of the IG to stop:
    ig stop -c "bootstrapGateways=localhost:721" -n ShoppingCartIG
    

Result

Once an Invocation grid has been started, client applications can run Cache.Invoke operations in your invocation grid.

// Call Cache.Invoke from a client application, specifying
// the name of the invocation grid to use:
var invokeResponse = cache.Invoke("TotalBackorderedValue",
                              param: null,
                              invocationGrid: "ShoppingCartIG");

switch (invokeResponse.Result)
{
    case ServerResult.InvokeCompleted:
        decimal backorderdValue = MessagePackSerializer.Deserialize<decimal>(invokeResponse.ResultObject);
        Console.WriteLine($"Value of backordered items in carts: {backorderdValue}");
        break;
    case ServerResult.UnhandledExceptionInCallback:
        Console.WriteLine("Unhandled exception(s) were thrown from invocation handler.");
        string exceptionInfo = Encoding.UTF8.GetString(invokeResponse.ErrorData);
        Console.WriteLine(exceptionInfo);
        break;
    default:
        Console.WriteLine($"Cache.Invoke returned unexpected {invokeResponse.Result}");
        break;
}
Note

Use the ig build command if you want to build and package your project without deploying it to ScaleOut hosts. The zipped up package can be deployed later using the ig start command with the -z flag.

If the Invocation Grid project needs to be updated, the project can simply be redeployed by running the ig start command again. The ScaleOut hosts will be notified of the new worker process code, stop the existing worker process, and deploy/launch the new version.