LOCAL_TO_LOCAL

The LOCAL_TO_LOCAL service type can be used to subscribe to Diffusion topics in the local server and publish their updates to another topic path in the same local server. Thus, for this service type, the local server acts as both source and target server.

This service type also supports the on-demand publication feature which can be enabled to publish to different Diffusion topics in the local server only if there is a demand or a trigger.

Ideally, a local to local service type is used to consume data from a source topic, transform the updates and publish to another topic path in the same server. It can also be used to replicate the updates from one topic path to another in the same Diffusion server.

There can be multiple instances of this service type, added to the adapter, to consume data from different Diffusion topics in the local server and publish the updates to different topics in the same local server, using different configurations.

Complete configuration for this service consists of framework required configuration for hybrid service and this service type specific configuration.

Example 1. Sample configuration for a service of type LOCAL_TO_LOCAL
    {
      "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)>",
          "replicateTopicType": true
        }
      }
    }

Framework configuration

This service type is of Hybrid service mode. Hence, it contains the framework configuration for both Sink and Source service modes. Details about supported configuration parameters for framework configuration for Hybrid service can be found here.

Application configuration

The supported application configuration parameters for this service type are defined in the table below:

LOCAL_TO_LOCAL service application configuration
Name Type Description Mandatory Default value

topicMappingFunction

String

A function to map the source Diffusion topic path on the local server, to construct a target topic path to publish updates to.

Yes

N/A

replicateTopicType

boolean

A boolean value to specify whether to publish to a topic with the same topic properties as the source topic in the local server. Setting this to false means that those specified in the framework configuration or default values will be used.

No

true

removeStaleTopic

boolean

A boolean value to specify whether to remove the target topic, when the source topic in the local server becomes unavailable.

No

true

onDemandPublication

onDemandPublicationConfig

Configuration to specify on-demand topic publication.

No

null

Since this service does not publish to a remote server, it does not require any remote server specific configurations. Hence, it will ignore the shared configuration, if specified.

Data subscription, conversion and publication to local server

When a LOCAL_TO_LOCAL service is added and started, the framework subscribes to any topic paths that match the configured Diffusion topic selector in the local server, defined in the diffusionTopicSelector within the framework configuration (if onDemandPublication is specified in the application configuration, the subscription occurs only after there is a demand or a trigger in the remote server). Any updates to the subscribed Diffusion topics are received and converted as configured and published to another topic in the local server which is defined with topicMappingFunction. Since this service publishes to the same server, setting topicMappingFunction to <path(0)> is not allowed as the target topic path should be different from the source. See Topic mapping function for more details on how the source topic path is mapped to a target topic path using the given mapping function.

By default, the topic type of the source topic will be replicated to the target topic. If the source topic is time series, time-series-specific properties which are timeSeriesRetainedRange and timeSeriesSubscriptionRange will also be replicated. However, if the configuration for the service also configures the target topic to be time series, time-series-specific properties specified in the configuration will be used instead of those in the source topic to create the target topic. This behavior is configurable using the replicateTopicType configuration parameter. If it is set to false, then the topic type specified via the topicType in the topicProperties or payloadConverter parameter in the source framework configuration will be used to identify the topic type to be created and configuration in topicProperties will be used for the topic specification. If neither topicType nor payloadConverter parameters are defined explicitly, default values will be used. By default, JSON topics will be created. See framework required configuration for default topic properties.

For a deeper understanding of how payload converters are used, please refer here. See here for the list of all issued payload converters by the framework.

As an illustration, consider the following sample configuration for a service of type LOCAL_TO_LOCAL. This service subscribes to the Diffusion topic doubles, which produces updates of type DOUBLE. No other configuration is specified, and the default value for replicateTopicType is used, which is true. Hence, the updates for the doubles topic will be published to another topic fromLocal/doubles of type DOUBLE in the same local server.

    {
      "serviceName": "doublesPublisher",
      "serviceType": "LOCAL_TO_LOCAL",
      "description": "Publishes to another Diffusion topic of same type using same properties as the source topic",
      "config": {
        "framework": {
          "sink": {
            "diffusionTopicSelector": "doubles"
          }
        },
        "application": {
          "topicMappingFunction": "fromLocal/<path(0)>"
        }
      }
    }

With the same doubles topic of DOUBLE topic type in the local server, in the example below, a payload converter is specified to be used that converts the data from the source topic to STRING type, and the replicateTopicType configuration is specified to be false. Thus, the update from the source topic will be converted to STRING topic type and published to the local server in the fromLocal/doubles topic path.

    {
      "serviceName": "doublesPublisher",
      "serviceType": "LOCAL_TO_LOCAL",
      "description": "Publishes to another Diffusion topic of STRING type",
      "config": {
        "framework": {
          "sink": {
            "diffusionTopicSelector": "doubles"
          },
          "source": {
              "payloadConverters": [
                {
                    "name": "$Object_to_String"
                }
              ]
          }
        },
        "application": {
          "topicMappingFunction": "fromLocal/<path(0)>",
          "replicateTopicType": false
        }
      }
    }

In the above example, if the payload converter is not specified in the source framework configuration, the topics published to will be of the default type, which is JSON.

    {
      "serviceName": "doublesPublisher",
      "serviceType": "LOCAL_TO_LOCAL",
      "description": "Publishes to another Diffusion topic of JSON type",
      "config": {
        "framework": {
          "sink": {
            "diffusionTopicSelector": "doubles"
          }
        },
          "application": {
            "topicMappingFunction": "fromLocal/<path(0)>",
            "replicateTopicType": false
          }
        }
    }

See Configuring the adapter for a complete example of the configuration for the adapter with configuration for LOCAL_TO_LOCAL services.