Configuring the adapter

Prerequisite: See configuring Gateway Application for an overview on how to configure a Gateway application.

The structure of the configuration for the Diffusion adapter is similar to that of any Gateway application, with the difference being the configuration for supported service types, sharedConfig types, and global configuration for the application.

A sample configuration file for the Diffusion adapter, which contains configuration for publishing and subscribing services, DIFFUSION_SERVER sharedConfig, and configuration for metrics is presented below:

Example 1. Sample configuration file
{
  "id": "diffusion-adapter-1",
  "framework-version": 1,
  "application-version": 1,
  "diffusion": {
    "url": "ws://localhost:8090",
    "principal": "admin",
    "password": "password",
    "reconnectIntervalMs": 5000
  },
  "sharedConfigs": [
    {
      "sharedConfigName": "remoteDiffusionServer",
      "sharedConfigType": "DIFFUSION_SERVER",
      "description": "The Diffusion server connection detail of the remote server",
      "config": {
        "application": {
          "diffusion": {
            "url": "ws://localhost:7090",
            "principal": "admin",
            "password": "password",
            "reconnectIntervalMs": 5000
          }
        }
      }
    }
  ],
  "services": [
    {
      "serviceName": "fxConsumerReplicated",
      "description": "Replicates topics from remote topic and publishes to local",
      "serviceType": "STREAM_FROM_REMOTE",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "application": {
          "topicMappingFunction": "fromRemote/replicated/<path(0)>",
          "diffusionTopicSelector": "?fx//",
          "updateMode": "STREAMING",
          "replicateTopicType": true
        }
      }
    },
    {
      "serviceName": "fxConsumerConverted",
      "description": "Consumes from remote topic and publishes to local into default-JSON type",
      "serviceType": "STREAM_FROM_REMOTE",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "application": {
          "topicMappingFunction": "fromRemote/converted/<path(0)>",
          "diffusionTopicSelector": "?fx//",
          "updateMode": "STREAMING",
          "replicateTopicType": false
        }
      }
    },
    {
      "serviceName": "fxConsumerConvertedString",
      "description": "Consumes from remote topic and publishes to local into configured String type",
      "serviceType": "STREAM_FROM_REMOTE",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "framework": {
          "topicProperties": {
            "timeSeries": true,
            "topicType": "STRING"
          }
        },
        "application": {
          "topicMappingFunction": "fromRemote/converted/string/<path(0)>",
          "diffusionTopicSelector": "?fx//",
          "updateMode": "STREAMING",
          "replicateTopicType": false
        }
      }
    },
    {
      "serviceName": "fxConsumerReplicatedOnDemand",
      "description": "Replicates from remote topic and publishes to local if there is demand in local",
      "serviceType": "STREAM_FROM_REMOTE",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "application": {
          "topicMappingFunction": "fromRemote/ondemand/<path(0)>",
          "updateMode": "STREAMING",
          "replicateTopicType": true,
          "onDemandPublication": {
            "triggerTopicBranch": "fx/"
          }
        }
      }
    },
    {
      "serviceName": "fxConsumerReplicatedOnDemandAsTrigger",
      "description": "Replicates from remote topic and publishes to local when there is a trigger in local",
      "serviceType": "STREAM_FROM_REMOTE",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "application": {
          "diffusionTopicSelector": "?fx//",
          "topicMappingFunction": "fromRemote/ondemand/triggered/<path(0)>",
          "updateMode": "STREAMING",
          "replicateTopicType": true,
          "onDemandPublication": {
            "triggerTopicBranch": "trigger/"
          }
        }
      }
    },
    {
      "serviceName": "tradeConsumerReplicated",
      "description": "Replicates from local topic and publishes to remote",
      "serviceType": "STREAM_TO_REMOTE",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "framework": {
          "diffusionTopicSelector": "?trade//"
        },
        "application": {
          "topicMappingFunction": "fromLocal/replicated/<path(0)>",
          "publicationRetries": 5,
          "retryIntervalMs": 5000
        }
      }
    },
    {
      "serviceName": "tradeConsumerConverted",
      "description": "Consumes from local topic and publishes to remote into configured-JSON topic type",
      "serviceType": "STREAM_TO_REMOTE",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "framework": {
          "diffusionTopicSelector": "?trade//"
        },
        "application": {
          "topicMappingFunction": "fromLocal/converted/<path(0)>",
          "topicProperties": {
            "topicType": "JSON",
            "timeSeriesRetainedRange": "last 2H",
            "timeSeries": true
          },
          "publicationRetries": 5,
          "retryIntervalMs": 5000
        }
      }
    },
    {
      "serviceName": "tradeConsumerReplicatedOnDemandWhenTriggered",
      "serviceType": "STREAM_TO_REMOTE",
      "description": "Replicates topics matching '?trade//' selector from the local server to remote only when there is trigger subscription in the remote server",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "framework": {
          "diffusionTopicSelector": "?trade//"
        },
        "application": {
          "onDemandPublication": {
            "triggerTopicBranch": "trigger/"
          },
          "topicMappingFunction": "fromLocal/onDemand/triggered/<path(0)>"
        }
      }
    },
    {
      "serviceName": "tradeConsumerReplicatedOnDemand",
      "serviceType": "STREAM_TO_REMOTE",
      "description": "Replicates topics of branch 'trade/' from local server to remote only when there is demand in remote server",
      "config": {
        "sharedConfigName": "remoteDiffusionServer",
        "application": {
          "onDemandPublication": {
            "triggerTopicBranch": "trade/"
          },
          "topicMappingFunction": "fromLocal/onDemand/<path(0)>"
        }
      }
    },
    {
      "serviceName": "replicateWeatherService",
      "description": "Publishes local weather data into another path with the same properties as the source path",
      "serviceType": "LOCAL_TO_LOCAL",
      "config": {
        "framework": {
          "sink": {
            "diffusionTopicSelector": "?weather//",
            "updateTimeoutMs": 180000
          }
        },
        "application": {
          "topicMappingFunction": "fromLocal/replicated/<path(0)>"
        }
      }
    },
    {
      "serviceName": "convertWeatherService",
      "description": "Publishes local weather data to a JSON topic at another path",
      "serviceType": "LOCAL_TO_LOCAL",
      "config": {
        "framework": {
          "sink": {
            "diffusionTopicSelector": "?weather//",
            "updateTimeoutMs": 180000
          },
          "source": {
            "topicProperties": {
              "topicType": "JSON",
              "timeSeries": true
            }
          }
        },
        "application": {
          "topicMappingFunction": "fromLocal/converted/<path(0)>",
          "replicateTopicType": false
        }
      }
    }
  ],
  "global": {
    "framework": {
      "metrics": {
        "enabled": true
      }
    },
    "application": {
      "prometheus": {
        "port": 8020,
        "path": "/metrics"
      },
      "jmx": true
    }
  }
}

Configuration version

The application configuration version this adapter supports is 1.

The framework configuration version expected by the framework used with this adapter is also 1.

Hence, the configuration for the adapter should be created with the following configuration versions:

{
    ...
    "framework-version": 1,
    "application-version": 1
    ...
}