Configuring Java CAPS JBI Components for GlassFish Clustering

Configuring the FTP Binding Component for Clustering

When the FTP BC is implemented in a cluster, all service provider instances poll requests simultaneously, business logic is applied to those requests simultaneously, and responses are posted simultaneously. Similarly, all service consumer instances post requests simultaneously. The FTP BC is highly available, and a failure of any instance does not stop message transfer. Messages are processed evenly among the pollers to balance the workload.

In on-demand read mode, each file is available to read from either all the instances (configuration mode) or only one instance (payload mode). In outbound mode, configure all instances to write to independent files rather than appending to one file. Using a UUID or persisted sequence number pattern in outbound file names ensures that files are not overwritten.

In inbound mode, the FTP BC distributes files evenly across the instances in a cluster, and each file is delivered to only one instance. You do need to configure a file locking mechanism to ensure files are not overwritten and to prevent redundant processing. This is configured by defining a persistence directory in the FTP BC's JVM options (described in the instructions below).

The FTP BC processes messages as follows using the locking mechanism:

  1. Acquire the file lock.

  2. If the file lock is acquired, continue processing; otherwise release the thread lock.

  3. Poll the target.

    • If the poller is retrieving a request, the target is ftp:message/@messageRepository/inbox/messageName or ftp:transfer/@receiveFrom.

    • If the poller is retrieving a response, the target is ftp:message/@messageRepository/outbox/messageName or ftp:transfer/@sendTo.

  4. If the message is retrieved successfully, archive the file so it will not be polled again.

  5. Release the file lock.

The FTP BC is dependent on the following shared library:

Adding the FTP Binding Component to the Cluster

The FTP BC is dependent on the following shared library:

ProcedureTo Add the FTP Binding Component to the Cluster

  1. Add the following shared library to the cluster as described in To Add a Shared Library to a Cluster:

    • sun-encoder-library

  2. Add the FTP BC to the cluster as described in To Add a Java CAPS JBI Component to a Cluster.

    The name of the FTP BC node is sun-ftp-binding.

  3. Before you click OK on the Manage Targets page, configure the runtime properties as you typically would for the FTP BC.

  4. Configure the JVM properties for the FTP BC by doing the following:

    1. In the left navigation panel of the Admin Console, expand Configurations, expand cluster_name-config, and then select JVM Settings.

    2. Click the JVM Options tab.

    3. To enable clustering, click Add JVM Option and enter the following in the empty row that appears:


      -Dcom.sun.jbi.ftpbc.isClustered=true
    4. To define a file-based persistence directory, click Add JVM Option and enter the following in the empty row that appears:


      -Dcom.sun.jbi.ftpbc.token.persistence.url=persistence_directory
      

      where persistence_directory is the location where the FTP BC lock files are stored.

    5. Click Save.

    6. Restart the cluster to pick up the changes to the JVM options.

Configuring the FTP BC WSDL for Clustering

The FTP BC has no runtime configuration requirements for clustering, but there are a few requirements and options for configuring the properties in any FTP BC WSDL documents deployed to the cluster. These options assist with concurrency issues and load balancing

To ensure that output files are not overwritten by concurrent threads, you can specify a pattern for the output message name using either %u or %seq_name to keep all file names unique.

ProcedureTo Configure the FTP BC WSDL for Clustering

  1. For outbound messages, do the following:

    1. In the FTP BC WSDL document, scroll to the input message definition under Bindings (named ftp:message or ftp:transfer, by default).

    2. Select ftp:message or ftp:transfer.

      The Properties panel displays the properties for the message.

    3. Do one of the following:

      • For ftp:message, modify the messageName property to use a unique pattern.

        Use either %u to assign a unique UUID number to each output file, or %seq_name for persisted sequence number creation.

        For example, output%u.txt.

      • For ftp:transfer, modify the sendTo property to use a unique pattern.

        Use the same patterns as described above.


      Note –

      Do not use %d in the file name because files might be overwritten.


    4. Save and close the WSDL file.

  2. To define a directory where recovery logs, malformed messages, and so on are stored, set the ftp:address/@baseLocation WSDL attribute to the full path.