Thursday, July 12, 2012

How to clear replication queue in CQ / WEM

Use Case

Case 1: Your replication queue is blocking and you have no idea why it is not getting processed.
Case 2: Some one accidentally activated thousands of pages and you want to clean them now.
Case 3: You want safe way to remove replication jobs and then activate them again if required
Case 4: You want to clean a dummy or problematic replication agent

Pre requisite : CQ5.4 or CQ5.3 with replication fix pack.

Solution :

1) Install attached package using package manager

2) Go to http://<host>:<port>/apps/tools/components/cleanReplication/run.html Or go to http://<host>:<port>/etc/replication/ click on your agent and you will will have options.

3) First do dry run and see if entries are getting deleted

4) Then check all checkbox and click on run clean replication.

5) There is also a failed replication Listener configuration, You can configure it to send an email in case replication fails.

Here are some screen shot

Here is package:

For CQ5.4:

Q: What will go to failed queue
A: Replication Job failed even after max retry.

Q: Why not use clear replication from replication page to remove entry ?
A: Some time you won't see entry to remove. And some time you have a lot of items in queue that is not easy to remove using UI. Some time you want to delete just specific entry and they are a lot (In that case you can use filter). See use case for more detail.

Note: Since the way replication data is stored in repository changes a lot over time this might not work with earlier version of CQ till CQ5.3. You can also remove unwanted code and change it according to your Need. If there is some problem let me know and given time I can look in to it. 

Special thanks to Henry Saginor from Adobe for providing code for failed replication listener. 


  1. Where is the replication fix pack for 5.4?

    1. Hello,

      You can get replication fix for CQ5.4 from Daycare. Please open a daycare ticket and ask for replication fix.


  2. Hi Yogesh,

    Will this work for CQ5.5?


  3. Hi Yogesh,
    I have found and issue when entering {authorServer}/etc/replication/agents.publish.html
    I receive NullPointerException.
    The reason is /apps/cq/replication/components/agents/agents.jsp
    which uses agentMgr.getAgents() that contains only agents active on current machine (author)
    Therefore any call to agent.getId() causes NPE.
    Easy fix could be adding following code at 110 line:
    String agentId = (agent == null) ? id: agent.getId();
    and using agentId then.

  4. This comment has been removed by the author.

  5. Hi, i want to set a separate queue for replication of some specific data. Is it possible in CQ. How to direct the replicated data to the new queue.

    1. You need to create custom queue for that. What is the use case ?

  6. Hi Yogesh,

    the job in the queue can be due to activate/deactivate/delete/ workflow.How these different events are handled after starting the " Clean Replication"

    1. They are not for now. But feel free to change code to check the status before performing your operation.

  7. Hi Guys
    Problem : I am working with 2 Author instances ( Clustered with Master / Slave ) and a publish Instances . I am activating 600 pages using Replicator API . All pages are getting activated but in replication queue of publish agent i can still see 6 page getting stuck though i have verified through logs that these pages have been activated.
    Can you please let me what could be the possibility ?

    ---Using AEM 5.6.1
    Your help will be appreciated :)

    1. This could be bug in replication UI. Please create a daycare ticket to fix this.

  8. Hi Yogesh,
    Is there any way to reverse replicate images present under /content/dam/[projectfolder] from publish instance to author instance in AEM 6.1?
    Please suggest someway

    1. Hello Sri,

      What is your requirement ?

      Case 1: If you want images to be available on author to do some operation and then replicate it back to publish.
      Please refer Reverse Replication and then in your publish you can have event handler to do reverse replication on content add.

      Case 2: if you want images to be available only on all publish instance if they are uploaded on one publish instance.

      In this case I would suggest to use shared datastore (NAS or something) Store Configurations