Build and configure the XA connector for the RDBMS

The EDB PostgreSQL module provides two-phase commit support using PostgreSQL-provided SQL calls, and ensures that any database connections made using this switch module all participate in a single XA transaction.

PostgreSQL Server configuration for XA

Important: Before you can use the EDB PostgreSQL RM Switch Module, you must configure the PostgreSQL Server by changing the value of the max_prepared_transactions property from its default value of 0 (zero) to a value greater than 0. After making this change, you must restart the postgresql server before proceeding. For additional details about the max_prepared_transactions configuration property, see your PostgreSQL product documentation.

Windows Environments

Source Code
The EDB PostgreSQL RM switch module COBOL source file, ESPGSQLXA.CBL is located by default in the %ProgramFiles(x86)%\Micro Focus\Enterprise Developer\src\enterpriseserver\xa directory.
Note: If you prefer to supply user credentials programatically rather than in the xa_open string, instructions for doing so are provided in the COBOL source file in the Customization section.
Build Requirements
To build the EDB PostgreSQL RM switch module, you must have the Windows Software Development Kit (SDK) installed for your version of Windows.

Before building this switch module, ensure that your LIB environment variable contains the path to the odbc32.lib file, located in a subdirectory under your Windows SDK LIB directory.

Building the Switch Module
Method 1
  1. Start an Enterprise Developer command prompt, 32-bit or 64-bit depending on the application, running as an administrator.
  2. Change to the %ProgramFiles(x86)%\Micro Focus\Enterprise Developer\src\enterpriseserver\xa directory (default location).
  3. Enter build pg [directives]
Method 2
  1. Start an Enterprise Developer command prompt, 32-bit or 64-bit depending on the application.
  2. Copy all files from the %ProgramFiles(x86)%\Micro Focus\Enterprise Developer\src\enterpriseserver\xa directory (default location) to any location where you have WRITE permission.
  3. Change to the directory containing the copied files.
  4. Enter build pg [directives]
Build Output
The build process produces two binary switch module files from the ESPGSQLXA.CBL COBOL source file:
Binary File Type
ESPGSQLXA_S.DLL static
ESPGSQLXA.DLL dynamic

You can register an RM switch module with Enterprise Server dynamically, or register it statically depending on which binary file you use. We recommend that you use the dynamic switch module option, as this ensures that only active databases used in the global transaction participate in the TM/RM XA flow.

UNIX Environments

Source Code
The EDB PostgreSQL RM switch module COBOL source file, ESPGSQLXA.CBL is located by default in the $COBDIR/src/enterpriseserver/xa directory.
Note: If you prefer to supply user credentials programatically rather than in the xa_open string, instructions for doing so are provided in the COBOL source file in the Customization section.
Build Requirements
The build script uses the current effective working mode to determine how to build the switch module.
Building the Switch Module
The $COBDIR/src/enterpriseserver/xa directory contains the build script file that you can use to build the switch module.
  1. Copy all files from the $COBDIR/src/enterpriseserver/xa directory (default location) to any location where you have WRITE permission.
  2. Change to the directory containing the copied files.
  3. Enter build pg
Build Output
The build process produces four binary RM switch module files from the ESPGSQLXA.CBL COBOL source file:
ESPGSQLXA.so 32-bit dynamic
ESPGSQLXA64.so 64-bit dynamic
ESPGSQLXA_S.so 32-bit static
ESPGSQLXA64_S.so 64-bit static

You can register an RM switch module with Enterprise Server dynamically, or register it statically depending on which binary file you use. We recommend that you use the dynamic switch module option, as this ensures that only active databases used in the global transaction participate in the TM/RM XA flow.

All Environments

Additional Resources
For more information on using the EDB PostgreSQL RM switch module, including the xa_open string definition, see EDB PostgreSQL xa_open string.

Creating an XA Resource

Your enterprise server region requires an XA resource for each datastore that contains one or more transactional files. If the database containing the datastore is also used by other COBOL applications, additional XA resources are required. Refer to Working with Multiple XARs for details on how to handle such situations.

  1. In the table of servers on the Home page of Enterprise Server Administration, click Edit to the left in the row for the enterprise server region that references the transactional data file.
  2. Click the XA Resources tab.
  3. Specify the following XAR details:
    Option Description
    ID Unique ID for the XAR.
    Name Unique name for the XAR.
    Module Specify the location of the RM switch module executable file (.dll on Windows or .so on UNIX platforms). This is database specific: esmssql.dll/.so for MSSQL and Azure SQL, ESPGSQLXA.dll/.so for PostgreSQL, and ESDB2XA.dll/.so for Db2. Refer to Building RM Switch Modules for more information.
    Open string DSN=<datastore-dsn>

    where <datastore-dsn> is the ODBC data source name of the datastore you are configuring.

    Note: These are only the mandatory options required, with the addition of USRPASS=userid.password if you are using a PostgreSQL database. You can also specify further options as required, as detailed in To Define an XA Resource (XAR) for an Enterprise Server Region.
  4. Select Enabled.
  5. Click OK.

    The XA resource should be effective immediately.