javaintegrationaemakamaipurge

How to integrate Akamai FastPurgeAPI into AEM using Java code?


I am trying to integrate FastPurge API into my AEM Event listener. I have read documentation but couldn't follow it.

Below, I have attached my listener.

public class PublishListener implements EventHandler() 
private static final Logger logger LoggerFactory.getLogger(PublishListener.class);

    public void handleEvent (Event event) {
    
    try {
    
    logger.info("in Event type:{}", event.getTopic());
    
    if (ReplicationAction, fromEvent (event).getType().equals(ReplicationActionType.ACTIVATE))
    
logger.info("\n Page Published: ()", ReplicationAction.fromEvent (event).getPath());
    
    if(ReplicationAction.fromEvent (event).getType().equals(ReplicationActionType.DEACTIVATE) || ReplicationAction.fromEvent (event).getType().equals(ReplicationActionType.DELETE)) 
`logger.info("In Page Deactivated: (), ReplicationAction.fromEvent (event).getPath())`;
    
    } 
catch (Exception e) {
    
    logger.info("in Error", e.getMessage());}}

Could you please help me to integrate the code with fastpurge API of akamai to purge?

Thanks in Advance!


Solution

  • The way we did it was to add replication actions carried out by an akamai replication agent - it was a fairly complex system to set up. Especially since all the dynamic includes on a given page need to be purged with their specific urls, not just the main published page (this may not be the case for you)

    use https://mvnrepository.com/artifact/com.akamai.edgegrid

    In the replicator, create an org.apache.sling.event.job.JobManager object and add a job for each url or set of up to 10 urls that need to be addressed (invalidated in akamai, usually).

    in each job, create the com.akamai.edgegrid.signer.ClientCredential and the ApacheHttpClientEdgeGridInterceptor and ApacheHttpClientEdgeGridRoutePlanner objects

    build the request according to the instructions you read - then build your post using the EdgeGridInterceptor and RoutePlanner with HttpClientBuilder

    then when you post it, it will get to the right place in akamai.