Configuring the data source and models for your LoopBack connector

Ensure that the data source for your LoopBack® connector has been configured.

Before you begin

Install the required LoopBack connector as described in Installing the LoopBack connector.

About this task

When you have installed a LoopBack connector to be used with IBM App Connect Enterprise, you must configure the data source for the connector, by adding a connector-specific data-source stanza to the datasources.json file.

Procedure

Follow these steps to configure the data source for your chosen LoopBack connector:

  1. Create or update a LoopBack datasources.json file, in the IBM App Connect Enterprise workpath/connectors/loopback directory. This datasources.json file can be specific to the integration node or the integration server.
    In most circumstances, the /connectors/loopback directory is created automatically; however, if it does not exist, you must create it.
    The LoopBackRequest node searches for its configured data-source stanza in the following order:
    1. workpath/integration_node/integration_server/connectors/loopback
    2. workpath/integration_node/connectors/loopback
    3. workpath/connectors/loopback
  2. Modify the datasources.json file by adding a JSON data-source stanza that configures the data source that you want to access.

    The LoopBack datasources.json file must provide all the properties that are required by the chosen connector. The details of the properties are defined by the installed LoopBack connector. For connecting to a secured connector, the security credentials can be provided in the datasources.json file; however, they are stored in plain text in the workpath folder. For an alternative approach to providing security credentials, see Specifying security credentials for connecting to a secured data source.

    The LoopBack datasources.json file can contain properties for multiple data sources; for example, it could contain the following code, which provides data-source stanzas for both a mongodb_dev and a mongodb_stage MongoDB connector:

    {
      "mongodb_dev": { 
        "name": "mongodb_dev",
        "connector": "mongodb",
        "host": "127.0.0.1", 
        "port": 27017,
        "database": "devDB", 
        "username": "devUser", 
        "password": "devPassword"
      },
      "mongodb_stage": {
        "name": "mongodb_stage",
        "connector": "mongodb",
        "port": 27018,
        "host": "staging.org.co.uk", 
        "database": "stageDB" 
      }
    }

    The content of the LoopBack datasources.json properties for the data sources are defined and used by the installed LoopBack connector; the LoopBackRequest node passes the JSON stanza to the installed connector when it is initialized at flow deployment or restart.

  3. Optional: You can provide a model definition file that is specific to the data-source stanza.
    Some LoopBack connectors require that the data model to be interacted with is defined through a LoopBack JSON model. When the LoopBackRequest node interacts for the first time with a named LoopBack object, which is either specified as a node property or dynamically overridden in the local environment, it looks for a LoopBack JSON model file in a subdirectory of the directory that contains the datasources.json file. This subdirectory, which you must create, must have exactly the same name and case as the data-source stanza that is specified on the LoopBackRequest node. For example, if the datasources.json file is provided only at the node location, the model would be:
    workpath/connectors/loopback/datasource_name/model_name.json
    The model_name part of the model_name.json file must match exactly (including the case) the LoopBack object name that is either specified on the LoopBackRequest node or overridden with the LocalEnvironment.Destination.Loopback.Request.object local environment variable.

    The name that is specified in the LoopBack object property of the LoopBackRequest node is the base name of the model file (excluding the .json file extension), and the name property in the model file defines the LoopBack object that will be interacted with. Typically, these names are the same, but they can be different; for example, if the name of the object in the LoopBack connected system contains a character that would be invalid in a file name. If the names are different, a BIP3880 message is issued.

    The following example shows how you could provide LoopBack JSON model files for working with the dev and staging MongoDB data sources:

    <workpath>
       \---connectors
             \---loopback
                 +---datasources.json
                 |
                 +---mongodb_dev
                 |   +---customer.json
                 |   +---order.json
                 |   \---test.json
                 |   
                 \---mongodb_stage
                     +---customer.json
                     \---order.json
    For more information about using models, see Using models with LoopBack connectors.

What to do next

Optionally, you can provide security credentials for the LoopBack connector by running the mqsicredentials command, as described in Specifying security credentials for connecting to a secured data source. Alternatively, you can use the mqsisetdbparms command.