XAP

Configuration

Getting Started

Creating a Processing Unit is simple:

  1. In Visual Studio, Create a new Class Library project.
  2. Add a reference to GigaSpaces.Core.dll from the product's bin folder.
  3. Add an xml file called pu.config to the project.
  4. Right-click pu.config, select Properties, and modify the Copy to Output Directory to Copy Always (or Copy If Newer).
  5. Copy the following configuration into pu.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="ProcessingUnit" type="GigaSpaces.XAP.Configuration.ProcessingUnitConfigurationSection, GigaSpaces.Core"/>
  </configSections>
  <ProcessingUnit>
    <!-- Processing unit configuration goes here -->
  </ProcessingUnit>
</configuration>

Upgrading from older versions The Processing Unit configuration scheme has been simplified in version 10.0, and the previous scheme is still supported for backwards compatibility but is deprecated. If you're upgrading from older versions it is recommended to update your PU configuration accordingly.

Embedded Spaces

The Processing Unit can be configured to create an embedded Space, which will be created when the PU is deployed and destroyed when the PU is undeployed:

<ProcessingUnit>
  <EmbeddedSpaces>
    <add Name="MySpace"/>
  </EmbeddedSpaces>
</ProcessingUnit>

Cluster Mode

When creating an embedded Space, the default proxy is created in direct mode, meaning it targets only the collocated cluster member. To target the entire cluster, set the Mode tag to Clustered:

<ProcessingUnit>
  <EmbeddedSpaces>
    <add Name="MySpace" Mode="Clustered"/>
  </EmbeddedSpaces>
</ProcessingUnit>

Cluster aware

When a Processing Unit is deployed, the configured embedded Spaces are created using the injected cluster information. To force an embedded Space to ignore that cluster info, use the ClusterInfoAware tag:

<ProcessingUnit>
  <EmbeddedSpaces>
    <add Name="MySpace" ClusterInfoAware="false"/>
  </EmbeddedSpaces>
</ProcessingUnit>

Space Properties

When creating a Space you can override Space properties values using the Properties tag:

<ProcessingUnit>
  <EmbeddedSpaces>
    <add Name="MySpace">
      <Properties>
        <add Name="space-config.engine.cache_policy" Value="0"/>
        <add Name="space-config.engine.cache_size" Value="100"/>
      </Properties>
    </add>
  </EmbeddedSpaces>
</ProcessingUnit>

Space Proxies

The Processing Unit can be configured to connect to a remote Space (hosted by another Processing Unit, for example):

<ProcessingUnit>
  <SpaceProxies>
    <add Name="MySpace"/>
  </SpaceProxies>
</ProcessingUnit>

Event Listeners

An event listener container is one of the most commonly used GigaSpaces components as part of a Processing Unit. Similarly to the other components, such event containers can be automatically detected, created and managed by the container - it will automatically detect classes decorated with EventDriven attributes (PollingEventDriven or NotifyEventDriven) and create corresponding event containers for them.

See Polling Container Component and Notify Container Component for more information regarding event listener containers.

[PollingEventDriven(Name="MyEventListener")]
public class MyEventListener
{
    [..]
}

An event listener container needs a Space proxy that will listen for events. If there's a single Space proxy configured it will be selected automatically, otherwise event container should be configured with the relevant Space name:

<ProcessingUnit>
  <EmbeddedSpaces>
    <add Name="Foo"/>
  </EmbeddedSpaces>
  <SpaceProxies>
    <add Name="Bar"/>
  </SpaceProxies>
  <EventContainers>
    <add Name="MyEventListener" SpaceProxyName="Foo"/>
  </EventContainers>
</ProcessingUnit>

Security

To access a secured Space the Credentials tag is used:

<ProcessingUnit>
    <EmbeddedSpaces>
        <add Name="EmbeddedSpace">
           <Credentials Username="user" Password="pwd"/> 
        </add>
    </EmbeddedSpaces> 

    <SpacesProxy>
        <add Name="RemoteSpace">
            <Credentials Username="user2" Password="pwd2"/> 
        </add>
    </SpacesProxy>     
</ProcessingUnit>

Assembly Scanning

By default, all the assemblies packaged with the Processing Unit will be scanned to automatically create Processing Unit components, event listener containers and remoting services. In some scenarios you may want to change this. For example:

  • The application uses many 3rd party assemblies, and scanning all of them slows down the deployment.
  • One of the assemblies contains troublesome code and you want to exclude it.
  • You're sharing code between multiple Processing Units and want to control which component is loaded in which Processing Unit.

You can use the ScanAssemblies tag to specify a list of assemblies to be scanned (wildcards may be used). In addition, you may specify a namespace prefix to which indicates only classes with that prefix will be scanned. For example:

<ProcessingUnit>
  <ScanAssemblies>
    <!-- Scan all assemblies starting with 'Foo.Bar.' -->
    <add AssemblyName="Foo.Bar.*.dll" />
    <!-- Scan all assemblies starting with 'MyCompany.' for classes starting with 'MyCompany.MyProject.'  -->
    <add AssemblyName="MyCompany.*.dll", NameSpace="MyCompany.MyProject."/>
  </ScanAssemblies>
</ProcessingUnit>

It is also possible to completely disable assembly scanning:

<ProcessingUnit>
  <ScanAssemblies Disabled="true"/>
</ProcessingUnit>

Finally, it is possible to configure the Processing Unit to scan for certain type of classes (components, event listeners and remoting). For example, to scan for event containers only:

<ProcessingUnit ScanRemotingServices="false" ScanBasicComponents="false" ScanEventContainers="true">
    <!-- Can be used in combination with ScanAssemblies -->
</ProcessingUnit>