Friday, October 28, 2011

How to set up User/Group/Profile reverse replication

Assumption: You are using CQ5.4

Use Case: You are creating users and group on publish and want to move them on author

Prerequisite: http://helpx.adobe.com/cq/kb/HowToUseReverseReplication.html

Solution:

Create two launcher on publish with run mode as publish which listen to rep:User and rep:Group on path /home/user and /home/group respectively and trigger reverse replication OR create one with rep:Authorizable and listen to /home
So it would be like

For User and Group Option 1

Event Type: Created
Nodetype: rep:User
Path: /home/users
Condition: cq:distribute!=
Workflow: /etc/workflow/models/reverse_replication
Run Mode: publish

AND

Event Type: Created
Nodetype: rep:Group
Path: /home/group
Condition: cq:distribute!=
Workflow: /etc/workflow/models/reverse_replication
Run Mode: publish

For User and Group Option 2

Event Type: Created
Nodetype: rep:Autherizable
Path: /home
Condition: cq:distribute!=
Workflow: /etc/workflow/models/reverse_replication
Run Mode: publish


For Profile

A. Code Changes
Change your code/form, that a profile update POST is adding
cq:distribute=true
source=authorname
as key=value into the /profile folder.

B. Setup on Publish Instance
Add Workflow Launcher Configuration:
Event Type: Modified
Nodetype: sling:Folder
Path: /home/users/(.*)/profile
Condition: cq:distribute!=
Workflow: /etc/workflow/models/reverse_replication
Run Mode: publish

C. Setup on Author Instance
Create Workflow Model:
One process step
Implementation: com.day.cq.wcm.workflow.process.ActivatePageProcess
Add Workflow Launcher Configuration:
Event Type: Modified
Nodetype: sling:Folder
Path: /home/users/(.*)/profile
Condition: source!=
Workflow: select your model created above
Run Mode: author


Important Note:
1) Above method will only work for created trigger. If you are modifying user profile on publish then you have to do same thing for modified trigger too.

2) If you have multiple publish instance then you have to make sure that all the publish instance are in sync. For that you need to again replicate those user back to other publish instance using launcher on author.
See an example how comment activation work. when user post a comment in publish instance a comment post servlet get called which add cq:distribute property to that node along with other properties -> this make node eligible for reverse replication -> publish instance put that node in outbox -> author reverse_publish agent poll data from publish and put it in /content/usergenerated -> Workflow launcher on Node Created /content/usergenerated of type cq:comment get called -> this calls workflow associated with it (Which is Comment Moderation workflow) -> workflow has logic to activate comment back to all publish instance based on whether it requires moderation or not (Simple replicator.replicate)


Thanks Cédric Hüsler from Adobe to provide this information

24 comments:

  1. Hi Yogesh,

    Is this still an issue with CQ5.5? Has reverse replication for user/group profile been addressed in 5.5?

    Thanks,
    Ron

    ReplyDelete
  2. Ron,

    I suppose it is same in CQ5.5 as well users and group will not be auto replicated. Hopefully it will get schedule for CQ5.6. You can always request for paid feature pack from Adobe for this though if you want this to be in product.

    Yogesh

    ReplyDelete
  3. I am replicating source VM from Hyper-v (I dont use host base replication recourse it in CSV cluster) to a target Hyper-v with VRA. How can I do fail back?

    ReplyDelete
  4. Hi Yogesh,

    Is there any good way to use package manager to export/import users, groups and their credentials and ACLs, as opposed to using the triggers and reverse replication ?

    ReplyDelete
    Replies
    1. Yes off course. Please see http://www.wemblog.com/2011/11/how-to-create-package-based-on-xpath-in.html for that. But using this approach might create some delay in synching across multiple publish server.

      Delete
  5. Currently I keep users/groups in a package hosted on Amazon S3, it is periodically built on the CQ host then sent to S3. Then new CQ instances get this package uploaded/installed from S3. I like this because it has a central repository and I can keep multiple hosts/versions.

    ReplyDelete
    Replies
    1. Yes. That is one option. Not sure how you are keeping all publish instance in sync then ? are they clustered ?

      Delete
  6. Hope you may have some insight I can't seem to find an answer for this :-( ...is it possible to place media in an S3 bucket and have DAM access it as a virtual repository (or some other way)

    ReplyDelete
    Replies
    1. Why not put Asset directly in CQ DAM ? That way you can have access to metadata as well. Other options I can think of accessing DAM through services like Scene 7 (Which is already integrated in CQ)

      Delete
    2. Hi, Thanks for the solution. I am using CQ5.5 and have followed all the steps for reverse replication mentioned above.
      But I have a doubt related to Profile , as given by you :
      Change your code/form, that a profile update POST is adding
      cq:distribute=true
      source=authorname ,
      as key=value into the /profile folder.

      Can you please explain what is the "source" property and what is the value set to this key. As , "source=authorname: is not working for me.
      If "authorname" is a value or just the variable used for some other value.

      Thanks in advance.
      Komal Arora

      Delete
    3. Komal,

      source is actually source of data. It could be publish instane name. It is optional.

      Yogesh

      Delete
  7. Hi Yogesh,
    When we reverse replicate from publish 1 to author and then forward replicate the node from author to all publish, will it hit all the rest of the publish instances or will it also include the publish instance (publish 1) from where it got the data from?

    ReplyDelete
    Replies
    1. I think yes. You can test this using comment moderation in OOTB CQ Geometrixx. Let us know your findings.

      Yogesh

      Delete
    2. Am asking because, if I add a launcher for node modification on author and publish to replicate and reverse replicate respectively, that might set an infinite loop if it is going back to the same publish instance. I hope CQ keeps track of where the change is coming from to not send it back again to the same instance. Will test it out. Thanks.

      Delete
  8. Hi Yogesh,

    We have a use case where in we have multiple sites on the cq authoring environment. Users & Group are created to take care of the Authoring of the content, review by another group and then publish and it works fine.


    For one of the site we need to do some change in the workflow wherein users in the group need to approve the content created/updated by other users of the group i.e. same user should not be able to create/update the content and publish it. It should be reviewed by other users in the group and only after approval, it will be published.


    I am looking for best practices for implementing this and how can we customize the workflow. Example would be extremely helpful

    ReplyDelete
  9. Hi All,

    We are also facing the same issue of the infinite loop. Any workaround/solution for this issue?

    Thanks
    Kamal

    ReplyDelete
    Replies
    1. Hello Gullu,

      Make sure that your workflow is set up properly to avoid infinite loop.

      Yogesh

      Delete
  10. Will this same Set up work for AEM-6.1 also?

    ReplyDelete
  11. I would suggest to use clustering with MongoDB (ASRP)

    https://docs.adobe.com/docs/en/aem/6-1/administer/communities/srp/asrp.html

    ReplyDelete
  12. Is this correct that profile node is sling:Folder, for me its nt:unstrucred.

    ...
    B. Setup on Publish Instance
    Add Workflow Launcher Configuration:
    Event Type: Modified
    Nodetype: sling:Folder
    Path: /home/users/(.*)/profile
    Condition: cq:distribute!=
    Workflow: /etc/workflow/models/reverse_replication
    Run Mode: publish
    ......

    Rohan

    ReplyDelete
    Replies
    1. Hello Rohan,

      Which version of CQ it is ? Is above configuration with sling:Folder working for you ?

      Yogesh

      Delete
  13. Hi Yogesh,
    Is there any way to synchronize images present under /content/dam/[projectfolder] between publish instances in AEM 6.1?

    ReplyDelete
  14. Hi Yogesh,

    Can we reverse replicate user to author in AEM 6.0 version ?

    Thanks and Regards
    Ajay Bhatt

    ReplyDelete
    Replies
    1. Hello Ajay,
      You should be able to do this similar to 5.6.1. Is it not working for you ? Also if it is part of community feature then I would suggest to use MSRP feature (Or similar) for AEM > 6 https://docs.adobe.com/docs/en/aem/6-1/administer/communities/srp.html

      Yogesh

      Delete