April 1, 2020
Estimated Post Reading Time ~

How to Disable Replication Agent using CURL in Adobe CQ / AEM

Use Case:
You want to disable replication agent without going to console.
You are doing a production deployment and want to disable replication agent
You want author not to replicate
You want dispatcher not to get flush 

solution:
# !/bin/bash
# Author: upadhyay.yogesh@gmail.com
# The host and port of the source server
SOURCE="localhost:4502"
# The user credentials on the source server (username:password)
SOURCE_CRED="admin:admin"

#Root path, You can change this path to target the only author or publish agent
ROOT_PATH="/etc/replication"

ALL_PATHS=`curl -s -u $SOURCE_CRED "$SOURCE/bin/querybuilder.json?path=$ROOT_PATH&type=nt:unstructured&1_property=cq:template&1_property.value=/libs/cq/replication/templates/%&1_property.operation=like&2_property=enabled&2_property.value=true&p.limit=-1" | tr ",[" "\n" | sed 's/ /%20/g' | grep path | awk -F \" '{print $4 "\n"}'`
echo "$ALL_PATHS"
for SINGLE_PATH in $ALL_PATHS
do
curl -s -u $SOURCE_CRED -F"enabled=false" $SOURCE$SINGLE_PATH
done

If you already know replication agent name you can also do the following,

for agent in flush flush1 {Other agent name}

do echo Disabling /etc/replication/agents.author/${agent}
curl -D- -o /dev/null -XPOST -F./enabled=false http://admin:admin@HOST:PORT/etc/replication/agents.author/${agent}/jcr:content 2>/dev/null done


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.