Klevr Product Documentation logo

Pub/Sub Model

An overview of the Klevr Integration Hub Pub/Sub model

Overview

Klevr Integration Hub uses a Publisher/Subscriber (Pub/Sub) model to allow integration stages to be joined together easily to create complete integrations.

In general, an integration will consist of 3 stages:

  • An inbound stage, where a payload comes "into" Integration Hub from a source system;
  • A transformation stage, where the payload is transformed in some way; and
  • An outbound stage, where the (transformed) payload is then sent "out" of Integration Hub to a destination system.

A complete integration may have fewer or more stages than this, however:

  • An integration may not require payload transformation (so there may only be an inbound and an outbound stage);
  • An integration may require multiple transformations;
  • The resulting payload from sending a payload "out" of Integration Hub to a destination system may need to be used as the payload for further stages;
  • etc.

In all of these situations, each stage (inbound, transform, outbound, etc.) "publishes" the details of its output (via a Service Bus message), but has no knowledge of the stage (or stages) that have been configured to "listen" to the message.

This allows subscriber stages to be created and deployed independently of publisher stages.

Pub/Sub Architecture

To make the Pub/Sub model easy to manage, Integration Hub uses the following architecture:

  • There is a Service Bus resource for each "Domain" in Integration Hub.
  • There is an Event Grid resource for each "Domain" in Integration Hub.

All stages in an Integration Hub "Domain" deployment must have a unique name.

  • A stage's name consists of the stage type code (e.g. "in-api" for the Inbound API Stage, etc.), plus a short descriptive name for the stage (e.g. "receive-order").

Every stage that publishes a message does so:

  • To the relevant "Domain" Service Bus resource; and
  • Using a queue that has the same name as the stage.

An Azure Function monitors the Service Bus queues, and when a message is detected, the message is retrieved from the Service Bus using peek-locking, and published:

  • To the relevant "Domain" Event Grid resource; and
  • Using a topic that has the same name as the stage.

All "downstream" stages that are intended to be triggered by an "upstream" message must subscribe to the relevant Event Grid topic of the "upstream" stage.

So, for example, imagine an integration for the cst domain, consisting of three stages:

in-api-example

  • The inbound stage that receives an inbound payload via an API.
  • All inbound payloads will be published via a message to the cst domain Service Bus.
  • The message is published to the in-api-example queue.
  • The Azure Function deployed by Integration Hub then transfers the message to the cst Domain Event Grid service, publishing the message using the in-api-example topic.

tr-lq-example

  • The transformation stage to be triggered by payloads from the inbound stage above.
  • Subscribes to the in-api-example topic in the cst Event Grid service.
  • On completion of the transformation, publishes the result via a message to the cst domain Service Bus.
  • The message is published to the tr-lq-example queue.
  • The Azure Function deployed by Integration Hub then transfers the message to the cst Domain Event Grid service, publishing the message using the tr-lq-example topic.

out-proxy-api-example

  • The outbound stage to be triggered by payloads from the transformation stage above.
  • Subscribes to the tr-lq-example topic in the cst Event Grid service.

In this way, each stage that wants to subscribe to a publisher stage can do so, without the publisher stage needing to having any prior knowledge of the subscriber(s).

See the Consumption vs. Standard Mode section for more details on correctly setting the source parameter depending on the deployment mode.

Cloud Event Payload Format

The Pub/Sub message format used in Integration Hub is based on the Cloud Event messaging standard.

An example format that will be received by Logic Apps/Logic App workflows is shown below:

{
  "id": "4625496b-1fec-4896-8937-235e608bf979",
  "source": "rt-loop-interface3",
  "type": "com.klevrapps.integration-hub.rt-loop-interface3",
  "data": {
    "BlobPath": "path/to/current/payload",
    "CorrelationId": "08585246696611732378379163277CU00",
    "RetryCount": null,
    "Attributes": {
      "in-sftp-interface1": "path/to/payload",
      "tr-lq-interface2": "path/to/payload",
      "rt-loop-interface3": "path/to/payload"
    },
    "FileMetadata": {
      "in-sftp-interface1": "{\"name\":\"file_name\", \"Size\": 123, \"Path\": \"path/file_name\", \"LastModified\": \"date_time_value\"}"
    }
    "Loops": {
      "rt-loop-interface3": 1 
    }
  },
  "time": "2023-02-20T23:54:00.6209024+00:00",
  "specversion": "1.0",
  "datacontenttype": "application/json",
  "traceparent": "00-5bb8397ee43b524c884186e190e7478d-338f9d13345ffd4c-00"
}

Last updated on