Multi assets replication Event | Community
Skip to main content
adivj95
Level 2
March 29, 2024
Solved

Multi assets replication Event

  • March 29, 2024
  • 4 replies
  • 833 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jineet_Vora

@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!

4 replies

Jineet_Vora
Community Advisor and Adobe Champion
Jineet_VoraCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
March 29, 2024

@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!

Saravanan_Dharmaraj
Community Advisor
Community Advisor
March 29, 2024

@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

 

aanchal-sikka
Community Advisor
Community Advisor
March 31, 2024

@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
kautuk_sahni
Community Manager
Community Manager
June 10, 2024

@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