cancel
Showing results for 
Search instead for 
Did you mean: 

Why does poolActionService not showing correct publication status?

Former Member
0 Kudos

I have this code snippet which is called every time a new file is to be processed for raw, canonical and target transformation to data hub. The idea is that it should not process the file if there is ongoing publication and composition in the data hub side. The issue I have is that there are instances that poolActionService returns the correct publication status and there are times it doesn't but when I check the database the publication status is different from the one returned by poolActionService (I am seeing SUCCESS in database but I see IN_PROGRESS from the one returned by poolActionService) I am using datahub and hybris commerce suite version 5.4. Any idea why this is happening? Or is there a better way to implement this checking before processing another feed?

I also have this config in our local.properties set as true.

kernel.flushBeforeQuery=true

Code Snippet:

 DataHubPool datahubPool = dataHubFeedService.findPoolByName(poolName);
 .
 .
 .
 List<PublicationAction> publicationActions = poolActionService.findPublicationActions(datahubPool);
 PublicationAction publicationActionLatest = null;
 for (PublicationAction publicationAction : publicationActions) {
     if (publicationAction.getStatus().equals(PublicationActionStatusType.IN_PROGRESS)) {
         return false;
     }
     if (publicationActionLatest == null) {
         publicationActionLatest = (PublicationAction) publicationAction;
         continue;
     } else {
         if (publicationAction.getActionId() > publicationActionLatest.getActionId()) {
             publicationActionLatest = publicationAction;
         }
     }
 }
 .
 .
 .
 if (publicationActionLatest.getStatus().equals(
             PublicationActionStatusType.SUCCESS)
             || publicationActionLatest.getStatus().equals(
                 PublicationActionStatusType.COMPLETE_W_ERRORS)
             || publicationActionLatest.getStatus().equals(
                 PublicationActionStatusType.FAILURE)) {
             // latest publication is complete. return true.
     return true;
 } else {
     // status is either IN_PROGRESS or empty.
     return false;
 }
     
 

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, seeing different results in the database and in the code usually is related to the different tid transaction scope. As an example your code checks a value in the DB but in the meantime until you query it manually in the DB it got changed already by a different thread.

To come back to your initial requirement. It is already solved using events. You can build a listener for PublicationCompletedEvent which can enable your file processing again after a load compose publish roundtrip was started. More documentation on events can be found here: https://wiki.hybris.com/display/release5/Data+Hub+Events+-+5.2+through+5.4

Answers (0)