Expand my Community achievements bar.

AEM - Offtime event Handler - Triggered in loops

Avatar

Level 2

Hello,

Disclaimer* I'm not a developer so apologies if I violate any taboos or don't say things correctly!

 

AEM Assets 6.5.15.

 

We are having an issue where our offtime event handler is looping over the same assets that reached offtime since April 28 2023 (this happens to be at least 2000 assets).

 

I've stabilized the system by taking the functionality out of the workflow triggered, however it is still looping every 15 min triggered by the event handler in question.

 

The function is to unpublish assets from Brand Portal when offtime is reached. We aren't using the OOTB offtime service as it had caused issues originally. This event handler has worked for over a year and there were no code changes for months. We did upgrade from 6.5.8 to 6.5.15 in Feb, but only noticed this problem  over the last couple weeks. It does not happen on lower environments. The loop seems limited to 1000 assets at a time. If we delete affected assets it moves on to other ones waiting in the wings. Unpublishing from brand portal manually does not seem to help it. The workflow completes without error.

 

I've narrowed it down to specific parts of the code.

 

@Override
public void handleEvent(Event event) {
final Object isOnTrigger = event.getProperty("isOnTrigger");
if (isOnTrigger == null) {
return;
}
final boolean isEventAnOffTime = !(Boolean) isOnTrigger;
if (isEventAnOffTime) {
runUnpublishWorkflow(event);
}
}
 
It looks like after being unpublished from Brand Portal, the "isOnTrigger" isn't being cleared or reset for these assets since the affected time period. (Again, this used to work without issue).
 
I can't find how to disable this or fix it without taking out the code entirely. 
 
At this point I just want to stop the workflow from triggering every 15 minutes on 1000 assets. Obviously i want to fix the functionality as well, but this is more important.
 
Any advice would be appreciated!
 
Thanks,

Mike
2 Replies

Avatar

Community Advisor

Hi @michaels1273561 , you may try this

 

@Override
public void handleEvent(Event event) {
    final Object isOnTrigger = event.getProperty("isOnTrigger");
    if (isOnTrigger == null) {
        return;
    }
    final boolean isEventAnOffTime = !(Boolean) isOnTrigger;
    if (isEventAnOffTime) {
        runUnpublishWorkflow(event);
        /*
          Remove the isOnTrigger property from resource here
          This would ensure that flow exit in next call
        */
    }
}

 

 

Hey @shubhanshu_singh 

Thanks for your reply!

 

unfortunately I can't find where this isOnTrigger is coming from, so I'm unable to correctly remove it.

 

At this point it would be good to find the source event so I can at least fix the looping manually and then look at deploying the code fix.

 

This code is working fine as is on our lower environments, so overall shouldn't require us to add to the code. Something weird is happening in our production environment only.

 

Thanks


Michael