Expand my Community achievements bar.

SOLVED

Multi assets replication Event

Avatar

Level 3

Hi Community

 

I have a requirement where when i select multiple assets and publish them , once all images got published i need to hit and external api and update the DB

So how can i check if all selected assets published and get list of the assets ??

 

Please help

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@adivj95 - I would suggest using a custom workflow which would:

  • In process step1: Replicate the selected assets selected. Replication can be done using Replication API and you can specify replication options to do synchronous replication (to ensure the assets are not stuck in queue)
    ReplicationOptions options = new ReplicationOptions();
    options.setSynchronous(true);
    replicator.replicate(resourceResolver.adaptTo(Session.class), actionType, paths[], options);​
  • In process step2: Hit the external API and update the DB

Hope this helps!

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

@adivj95 - I would suggest using a custom workflow which would:

  • In process step1: Replicate the selected assets selected. Replication can be done using Replication API and you can specify replication options to do synchronous replication (to ensure the assets are not stuck in queue)
    ReplicationOptions options = new ReplicationOptions();
    options.setSynchronous(true);
    replicator.replicate(resourceResolver.adaptTo(Session.class), actionType, paths[], options);​
  • In process step2: Hit the external API and update the DB

Hope this helps!

Avatar

Community Advisor

@adivj95 You can check this example replication event handler to run , it will look for Replication event. You have more control on adding logic to call the external API and send the list of assets. Please check it out. 

https://gist.github.com/floriankraft/3710f30f4eaf212410a3

 

Avatar

Community Advisor

@adivj95 

 

Once you publish the asset, you can probably trigger a job, which will:

  • Check the replication status of the queue
    • If queue is not empty, check the status after few minutes.
    • If the queue is empty, send the update request to DB

 

To check the status of the queue you can use following API:

AgentManager -> Agents (getAgents()) -> ReplicationQueue (getQueue()) -> getStatus()

 


Aanchal Sikka

Avatar

Administrator

@adivj95 Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni