CMP pipelines

Version: 3.0

The Sitecore Content Marketing Platform (CMP) connector adds one new processor to the <initialize> pipeline, and one new <cmp.importEntity> pipeline, including three new processors. The pipelines are defined in the App_Config/Modules/Sitecore.Connector.CMP/Sitecore.Connector.CMP.config file.

The initialize pipeline

The <initialize> pipeline is used to initialize the Azure Service Bus listener. For CMP, the following processor is added:

Processor

Description

InitializeServiceBus

Initializes the Azure Service Bus listener that runs the <cmp.importEntity> pipeline when a new message appears in the topic’s subscription.

The InitializeServiceBus processor does the following:

  1. Gets the config item, reads the connection information, and initializes a topic client and a subscription client.

  2. If a message is triggered, the ProcessMessagesAsync action is executed:

    • It runs the <cmp.importEntity> pipeline.

    • Then, it checks the ImportEntityPipelineArgs pipeline and sends a message back to the Bus. For example:

      RequestResponse
      { 
      
       
      "input_message_id": "1174",
      
       
      "item_id": "{D071EDAF-55A4-4CB0-9ED3-6AAB6288ECA5}",
      
       
      "target_id": 10436,
      
       
      "target_identifier": "Iqa356VYWEe-PsBiEcAgPg"
      
      "inputMessageId": "2446", "itemId": "{CD41DE03-1169-493C-A138-B7DD4722EBB8}" }
  3. Writes to the log file. For example:

    RequestResponse
    17580 11:48:16 INFO  Sitecore Connect for Sitecore CMP: Sending a message: {
      "input_message_id": "1174",
      "item_id": "{D071EDAF-55A4-4CB0-9ED3-6AAB6288ECA5}",
      "target_id": 10436,
      "target_identifier": "Iqa356VYWEe-PsBiEcAgPg"
    }
    24428 14:49:58 INFO Sitecore Connect for Sitecore CMP: Sending a message: { "inputMessageId": "2446", "itemId": "{CD41DE03-1169-493C-A138-B7DD4722EBB8}"
    }
    

The cmp.importEntity pipeline

The <cmp.importEntity> pipeline is used to import entities. It includes the following processors:

Processor

Description

FetchEntity

Gets an entity by ID.

The FetchEntity processor does the following:

  1. Creates the Content Hub client and gets the entity by ID (the target_id in the bus message) and puts it in the args to make it available to the next processors.

  2. Checks for the ContentToContentLocalization relation. If there is a parent entity, its identifier will be used, otherwise, the current entity’s identifier will be added to the args.

  3. Checks for the LocalizationToContent relation. If there is a parent entity, the processor will try to parse the parent’s ValueName property to a language. If there is no parent, the default language will be used. The language will be added to args to be available for the next processors. An exception is thrown if the processor fails to parse the language. If there is no LocalizationToContent parent, the exception will not be thrown.

  4. Checks for the ContentTypeToContent parent and puts its identifier to the args.

EnsureItem

Gets the entity mapping item and finds the EntityIdentifier field.

The EnsureItem processor does the following:

  1. Enumerates the children of the config item to find the entity mapping item that matches the content type identifier from the args.

  2. If the entity mapping item is found, it gets the corresponding item bucket item (it is configured in the entity mapping item).

  3. Tries to find an item that contains the EntityIdentifier field (Content Hub template)) equal to the EntityIdentifier in the args (it could be either the current M-entity identifier or its ContentToContentLocalization parent’s identifier). If there is already an item with such an EntityIdentifier, the processor gets it (a language version based on the args.Language) and put it into the args. If there is no such item, the processor creates it with a version in a given language (args.Language) and puts the item in the args.

SaveItem

Saves the item to Sitecore.

The SaveItem processor does the following:

  1. In a given language context (args.Language), it goes through field mapping items of the entity mapping item, and for each field mapping it gets a property value from the Content Hub entity and sets the value to the Sitecore item.

  2. Sets the publish date on a current version (if the date is not null).

Do you have some feedback for us?

If you have suggestions for improving this article,