Skip to Content
author's profile photo Former Member
Former Member

Why does poolActionService not showing correct publication status?

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;
 }
     
 

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 18, 2015 at 10:30 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.