Skip to Content
0
Former Member
Jul 05, 2018 at 02:52 PM

EvenListner to check Status of composition of SAPCONFIGURATION_POOL before product replication

45 Views

Hi All ,

My requirement is to check status of composition of SAPCONFIGURATION_POOL, before every product replication through pool :- GLOBAL

I tried below code, but this code is getting executed every time after SAPCONFIGURATION_POOL is call instead I want it to check before every product replication

Is their anything wrong ?

 package com.cgi.events.impl;
 
 import java.util.ArrayList;
 
 import com.hybris.datahub.api.event.CompositionCompletedEvent;
 import com.hybris.datahub.api.event.DataHubEvent;
 import com.hybris.datahub.api.event.DataHubEventListener;
 import com.hybris.datahub.api.event.DataHubPoolEvent;
 import com.hybris.datahub.api.event.InitiateCompositionEvent;
 import com.hybris.datahub.api.event.InitiatePublicationEvent;
 import com.hybris.datahub.dto.pool.PoolData;
 import com.hybris.datahub.runtime.domain.DataHubPool;
 import com.hybris.datahub.service.DataHubFeedService;
 import com.hybris.datahub.service.EventPublicationService;
 import com.hybris.datahub.service.PoolActionService;
 
 
 public class CompositionEventsListener implements DataHubEventListener<CompositionCompletedEvent> {
 
    
     private DataHubFeedService dataHubFeedService;
     private EventPublicationService eventPublicationService;
     
         
     
     @Override
     public void handleEvent(CompositionCompletedEvent event) {
         
         DataHubPool dataHubPool = dataHubFeedService.findPoolByName("SAPCONFIGURATION_POOL");
        
         Long poolId=dataHubPool.getPoolId();
         
         System.out.println("************composition event in side if loop*********************"+poolId);
         DataHubPool globalPool = dataHubFeedService.findPoolByName("GLOBAL");
         Long globalPoolId=globalPool.getPoolId();
         System.out.println("************composition event in side if loop*********************"+globalPoolId);
         
         if(poolId.equals(event.getPoolId()))
         {
             final InitiateCompositionEvent nextPublicationEvent = new InitiateCompositionEvent(globalPool.getPoolId());
             eventPublicationService.publishEvent(nextPublicationEvent);
             System.out.println("************composition event in side if loop*********************");
         }
     
     }
     
     
     
     @Override
     public boolean executeInTransaction() {
         // TODO Auto-generated method stub
         return true;
     }
 
     @Override
     public Class<CompositionCompletedEvent> getEventClass() {
         // TODO Auto-generated method stub
         return CompositionCompletedEvent.class;
     }
 
 
 
 
     public DataHubFeedService getDataHubFeedService() {
         return dataHubFeedService;
     }
 
     public void setDataHubFeedService(DataHubFeedService dataHubFeedService) {
         this.dataHubFeedService = dataHubFeedService;
     }
 
     public EventPublicationService getEventPublicationService() {
         return eventPublicationService;
     }
 
     public void setEventPublicationService(EventPublicationService eventPublicationService) {
         this.eventPublicationService = eventPublicationService;
     }
 
 
 }