Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SLING CONTENT DISTRIBUTION IN AEM (PART 2)

SLING CONTENT DISTRIBUTION IN AEM (PART 2)

This tutorial is the continuation of earlier tutorial on Sling Content Distribution in AEM, refer the following URL for part1 tutorial - SLING CONTENT DISTRIBUTION - SYNC USER AND CONTENT ON AEM AUTHOR AND PUBLISHERS (PART1)

In this tutorial let us see the details on Sling Reverse Distribution on AEM.

REVERSE DISTRIBUTION - DEFINITION

  • A reverse distribution setup allows one to transfer content from a farm of source instances(publisher) to a target instance(author). 
  • That is done by pulling the content from source instances(publisher) into the target instance(author).

sling-reverse-distribution
This will help us to sync the data generated in farms of publishers into the Author instances.

REVERSE DISTRIBUTION - CONFIGURATIONS

sling-reverse-distribution

  • configure a “queue” agent and package exporter on publisher(source instance)
org.apache.sling.distribution.Agent.impl.QueueDistributionAgentFactory-reverse.json            
    name="reverse"

org.apache.sling.distribution.packaging.impl.exporter.AgentDistributionPackageExporterFactory-reverse
    name="reverse"
    agent.target="(name=reverse)"
  • configure a “reverse" agent on author(target instance) pointing to the URL of the exporter on publish, multiple publisher endpoints can be configured
org.apache.sling.distribution.agent.impl.ReverseDistributionAgentFactory-reverse.json            
    name="reverse"
    packageExporter.endpoints=["http://localhost:4503/libs/sling/distribution/services/exporters/reverse"]

REVERSE DISTRIBUTION - DEMO

  • Configure Reverse Agent in Author
  • Configure Queue agent  and exporter on Publisher
  • Enable Triggers – Scheduled/JCREvent
  • Test – CURL/Triggers

Configure Reverse Agent in Author


Configure a Reverse Agent in Author that will PULL distribution content from publishers endpoints based on the configuration.

Access http://localhost:4502/aem/start.html, Tools - Deployments - Distribution

sling-content-distribution-aem



Create new Distribution agent of type - Reverse Distribution 

Enter a name - "reverse"
Title - "reverse"
Check "Enabled"
Service Name - Service name is optional, if required create a service user with required permission
Change the lo level if required
Add exporter endpoint URL's - the URL point to the publisher, multiple endpoint URL's can be configured, http://localhost:4503/libs/sling/distribution/services/exporters/reverse(reverse is the Queue Distribution agent name of publisher)

distribution-agent-aem


distribution-agent-aem



Save the configurations , the agent is created now but the status is paused 

distribution-agent-aem


Resume the agent by clicking on the resume button on the agent detail page.

distribution-agent-aem


distribution-agent-aem

The agent is now ready to Pull the distribution content from publisher.

Configure Queue agent and exporter on Publisher

Configure a queue agent that places the changes into the queues and an exporter that exports packages from the queue agent.

Access http://localhost:4503/aem/start.html, Tools - Deployments - Distribution

Create new Distribution agent of type - Queue
Enter a name - "reverse"
Title - "reverse"
Check "Enabled"
Service Name - Service name is optional, if required create a service user with required permission
Change the lo level if required
Allowed Roots - Add the root paths the agent is responsible for distribution e.g /content/we-retail(if required multiple root paths can be configured )

distribution-agent-aem


Save the configurations, Queue Distribution Agent is enabled now

distribution-agent-aem


Let us now configure Exporter

Access http://localhost:4503/system/console/configMgr/org.apache.sling.distribution.packaging.impl.exporter.AgentDistributionPackageExporterFactory

Enter name - "reverse"
The target reference for the DistributionAgent that will be used to export packages - "(name=reverse)", here "reverse" is the queue agent name configured in the previous step

distribution-agent-aem


Now the initial configurations are ready, let us test the reverse distribution scenario through curl commands

Modify some content under /content/we-retail node in publisher

distribution-agent-aem.

Execute the below curl commands

curl -u admin:admin http://localhost:4503/libs/sling/distribution/services/agents/reverse -d "action=ADD" -d "path=/content/we-retail/jcr:content"   (add the modified content to publisher Distribution queue)

distribution-agent-aem

Now the content is queued to the publisher distribution queue

distribution-agent-aem


curl -u admin:admin http://localhost:4502/libs/sling/distribution/services/agents/reverse -d "action=PULL" (PULL the content from publisher queue to author)

distribution-agent-aem

 Now the content is pulled to author

distribution-agent-aem

Let us now see how to automate the reverse distribution through triggers

Configure a JCR Event Trigger in Publisher


Configure a JCR Event Trigger in Publisher to add the JCR changes under the configured path to the Distribution queue

Access http://localhost:4503/system/console/configMgr/org.apache.sling.distribution.trigger.impl.JcrEventDistributionTriggerFactory

Enter name - "reverse-sync"
Path for which the changes are distributed - "/content/we-retail"
Service Name - Enter the service name with required access, i am using the default one for demo(socialpubsync-distributionService), the trigger will not be activated without configuring the service user
Use deep distribution - Enable this if want to distribute the subtree of the configured node on any events

distribution-agent-aem

Now link the trigger to the "Apache Sling Distribution Agent - Queue Agents Factory"  configured with the name "reverse" in the earlier step, Triggers - (name=reverse-sync)

distribution-agent-aem

Configure a Scheduled Event Trigger in Author

Configure a Scheduled Event Trigger in Author to pull the content from publishers Distribution Queue

Access http://localhost:4502/system/console/configMgr/org.apache.sling.distribution.trigger.impl.ScheduledDistributionTriggerFactory

Enter name - "reverse-sync"
Distribution Type - "PULL"
Distributed Path, the path to be distributed periodically- "/content/we-retail"
Service Name - Enter the service name with required access, i am using the default one for demo(socialpubsync-distributionService),  the trigger will not be activated without configuring the service user
Interval in Seconds - he number of seconds between distribution requests. Default 30 seconds

distribution-agent-aem


Now link the trigger to the "Apache Sling Distribution Agent - Reverse Agents Factory"  configured with the name "reverse" in the earlier step, Triggers - (name=reverse-sync)

distribution-agent-aem


Now the content modification from publisher under /content/we-retail node will be synced to author on every 30 seconds


This concludes the reverse distribution configuration between publisher and author, the content changes from publisher is pulled to author. We can configure multiple publisher endpoints in the Author reverse distribution agent to pull the content changes . The triggers can be configured in Author and Publishers to completely automate the reverse distribution of the contents. Let us continue with distribution sync in next tutorial.


This post first appeared on Albin's, please read the originial post: here

Share the post

SLING CONTENT DISTRIBUTION IN AEM (PART 2)

×

Subscribe to Albin's

Get updates delivered right to your inbox!

Thank you for your subscription

×