Starting GemFire XD Servers with the FabricServer Interface

The FabricServer interface provides an easy way to start an embedded GemFire XD server process in an existing Java application.

You generally use the FabricServer interface when you want to provide thin client connectivity to the embedded GemFire XD member. The FabricServer interface enables you to start multiple network services to listen for clients on different address and port combinations. Using the FabricServer interface also enables you to initialize resources in the GemFire XD server member before you start network services and make the member available to client connections.

Note: Although the FabricServer interface supports starting an embedded locator service, production systems should use standalone locators as a best practice. See Start and Stop Locators.


To start a GemFire XD server using the FabricServer interface:
  1. Use the FabricServiceManager factory class to obtain the singleton instance of FabricServer. For example:
    FabricServer server = FabricServiceManager.getFabricServerInstance();
  2. Create a Java Properties object and add all of the boot property definitions that you want to configure when starting the server. For example:

    Properties bootProps = new Properties();
    bootProps.setProperty("mcast-port", "12444");

    As an alternative, you can define properties as system properties (pass with the -D option to the JVM), configure them in a properties file, or rely on default property values. Configuration Properties provides more information.

  3. Use the FabricServer.start() method with start the server using your Properties object:
    Note: GemFire XD supports only a single FabricServer instance in a JVM at any given time. If you invoke start() multiple times using the same Properties, then no action is taken during subsequent calls. If you invoke start() multiple times using different properties, then by default the existing FabricServer instance is first stopped and then restarted with the new properties. You can optionally use the start(Properties bootProperties, boolean ignoreIfStarted) method with a "true" boolean value to reuse a previous instance instead of restarting it. See the FabricServer JavaDoc for more information.
  4. To support client connections, start a network service on a unique client and port combination using the startNetworkServer() method. You can specify the host and port number as arguments to the method. You can specify additional network server properties in a Properties object that you pass with the method. For example, to specify only the address and port with no additional properties:
    server.startNetworkServer("localhost", 1528, null);
    Note: The GemFire XD network server supports the Apache Derby network properties documented in the Derby Server and Administration Guide.
  5. Start additional network services as needed to listen on different address and port combinations.

Deciding When to Use Embedded Peer-to-Peer provides more examples of using the FabricServer interface to embed GemFire XD members.