Sitecore Connect™ for Sitecore CMP 2.0.0
Sitecore Connect™ for Sitecore CMP version 2.0.0 was released this week. It is a module that syncs content created in the Sitecore Content Hub to Sitecore XP.
The module has excellent documentation. Here, I want to explain how it works internally.
In Sitecore XP, the building blocks are called items. In Content Hub, they are called entities. Entities have fields and relations.
Suppose we create a blog post in English (en-US) in Content Hub. We now have an entity with properties such as Title and Body. A relation named ContentTypeToContent, from a Blog entity to our entity, identifies it as a blog post.
A relation named LocalizationToContent, from the en-US entity to our entity, marks the blog post as American English.
If we localize the blog post to nl-BE, Content Hub creates another blog post entity and links it to the nl-BE language entity through the LocalizationToContent relation. A ContentToContentLocalization relation also connects the English blog post to its Dutch (Belgium) localization.
Let's see how Sitecore Connect™ for Sitecore CMP 2.0.0 turns these entities into Sitecore XP items.
When an entity is published, a Content Hub trigger runs an action that sends a message to an Azure Service Bus topic called hub_out. The message contains the entity_id, and other systems can subscribe to the topic to learn about changes.
On the Sitecore XP side (CM), a subscription client listens for new messages in hub_out.
When a new message arrives, the cmp.importEntity pipeline starts.
The cmp.importEntity pipeline runs these three processors:
FetchEntity processor:
- Gets the
entity_idfrom the Service Bus message. - Gets the entity from Content Hub.
- Resolves the content language from the
LocalizationToContentrelation. - Resolves the localization parent, if one exists, from the
ContentToContentLocalizationrelation.
EnsureItem processor:
- Tries to find an item that corresponds to the entity.
- Searches the configured Item Bucket for an item whose
Entity Identifierfield matches either the current entity's identifier or, if one exists, the localization parent's identifier. - Sets the new item's
Entity Identifierfield. - If no matching item exists, creates one. It uses the language from the
LocalizationToContentrelation when available, or the default language otherwise.
SaveFieldValues processor:
- Saves the item fields configured for synchronization.
- After
cmp.importEntityfinishes, sends a message to another topic calledhub_in. This message contains the incoming message ID, item ID, entity ID and any exception.
Content Hub consumes the message and knows the status of the entity synchronization.
