Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Fetching Node Property during replication

Avatar

Level 4

Hi,

I might be bit silly to ask but please let me know if there is any Replication API which can fetch a property of a node during replication.

example:

I am getting path of the content which is getting replicated by replicationAction.getPath().

Is there any way i can fetch few properties from this path as well during replication. i need properties from Author Instance.

I need it for Akamai AEM SYNC.

Regards,

Anand

20 Replies

Avatar

Community Advisor

Hi,

Above methods returns the path which is string. From string you can get the Node and from Node you can get properties.

from workflow session you can get it like below -

Node node = (Node) session.getSession().getItem(path);

Node (Content Repository for Java Technology API Version 2.0)



Arun Patidar

Avatar

Level 4

But isnt it going to give properties from publish instance?

i need properties from author instance which are getting replicated on publish instance.

regards,

manish

Avatar

Employee Advisor

That's not possible. You cannot cross these boundaries that easily (for a good reason).

If you want authoring properties to be available on publish as well, you have to replicate them. In your case why don't you attach these properties on author to the node which is going to be replicated?

Jörg

Avatar

Level 4

Hi Jorg,

i have created an akamai agent which reads replication. I am trying to read a property at author and process my request at akamai.

if i attach a property to a node in author instance , and if i want to read it on publish instance than i need to replicate it first.

so basically for akamai,my author needs to replicate twice to read that property on publish.

i know durboimporter reads the properties from author during replication but is there any way to fetch properties during replication itself and make it available in my code?

i am fetching conteny path from replicationAction api. I could find any way to fetch properties also.

Regards,

Manish

Avatar

Community Advisor

You may try creating a servlet on publisher which will be called from author with credentials and pass path as parameter and as a response returns page properties from publishers.

Author publisher everything except cq:lastReplicationAction, cq:lastreplicated and cq:lastReplicatedBy

but in 1:M or M:M environments you may ended up of making multiple requests.



Arun Patidar

Avatar

Employee Advisor

Ok, you lost me. Can you add a diagram (or just a list) describing at which system you should add which data and where you intend to read it?

Jörg

Avatar

Level 4

i want to add a property in author and i want to fetch that same property during replication in publish.

i cant replicate to have that property in piblish and than again replicate to read that property.

i want that property during first replication.

Avatar

Level 4

Making to many calls will be a problem.

Avatar

Employee Advisor

Ok, let me try to rephrase it:

1) On author, you add a property "prop" to node "/home/mysite/en/jcr:content"

2) On author, this page is replicated (either through code, or triggered by an user)

3) On any publish, this replication request is received, and the property "prop" is now available on /home/mysite/en/jcr:content

4) On any publish: Your custom action

Is this the order of steps correct? Or did I miss one? Because right now I cannot match my list to your approach, so I am obviously missing something.

Jörg

Avatar

Level 4

Exactly..

but in third step during the replication i need the property to be available in my code.

it isnt published yet but it is in the process.. at that time the need to fetch this property.

is it possible?

Avatar

Level 10

Just wondering, why not use replication preprocessor?
Do you see any issue?

Avatar

Employee Advisor

Hi Manish,

ok, understood. So let's rephrase it into:

1) On author, you add a property "prop" to node "/home/mysite/en/jcr:content"

2) On author, this page is replicated (either through code, or triggered by an user)

3) On any publish, during replication, custom code needs to read the property "prop" on /home/mysite/en/jcr:content

So, how are you hooking into this process, that you can say "during the replication"? What API do you use (or want to use) to achieve this? And if you post your complete usecase, we might come up with a better and simpler solution.

Jörg

Avatar

Level 4

Hi edubey,

even if i preprocess it, will i be able to get property in publish instance from author?

i havent used it before. Correct me if i am wrong, doesnt it just check everything before replication?

but not actually replication.

Avatar

Level 4

Hi Jorg,

i have created an agent which reads replication and then triggers akamai cache invalidate.

i am adding a check rule for author to decide if they need this content to be invalidated at akamai.

hence i am adding a property at page level and thinking to read that property during replication on publish and validate the akamai cache request.

Regards,

Manish

Avatar

Employee Advisor

Hi Manish,

what do you mean with "which reads replication and then triggers akamai cache invalidation"? Have you created your own dedicated endpoint (similar to /bin/receive, but different), which reads the changed page from the headers? Then I understand the problems you are facing.

What about creating a new replication agent on publish, which has the trigger "on receive" set? This is only triggered when an incoming replication has already been processed. When you invalidate through a HTTP call, you can either build a custom transport handler (if you want to create the connection on your own) or just a custom content builder (if you need to build a custom payload format), but you don't need to implement the complete logic on your own.

Jörg

Avatar

Level 4

I have done exactly what you have written in second paragraph.

i have created my own contentBuilder and transportHandler.

i have created an agent on publish to process this akamai invalidate on RECEIVE.

but this invalidation process will be triggered as soon as it receives the replication, dont you think it will be too late for my code in publish to read this check property from author?

i tried this way but i was not able to read this check property during first replication.

Avatar

Employee Advisor

OK, now I understand.

OnReceive agents are triggered by Sling Events ("com/adobe/granite/replication"), and for every replication a new session is being opened. Technically it should see all changes of sessions which happened before the creation of this session. And I think that the Sling Event is being sent after the replication data has been persisted, the session available to your custom transporthandler and content builder should be able to see the data written by the incoming replication.

Do your contentbuilder and transport handler use a new session for their work? Potentially long-running?

Jörg

Avatar

Level 4

Hi Jorg,

Yes, I am using a new session in order to create a ReplicationContent only in ContentBuilder.

Just passing the created content to transport handler and making a call to akamai.

Regards,

Manish

Avatar

Employee Advisor

That's really strange, because then the session save of the replication receiver thread and the creation of your session must overlap.

Maybe you can add debug statemnets to your code, and also enable DEBUG logging on repo writes (see [1] how to do it); then you can compare timestamps of the save and the time of the creation of your session.

[1] What is writing to my Oak repository? | Things on a content management system