cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect if system is still initializing

adiputera
Active Participant
423

Hi All,

How can we detect that the system is still initializing?

We have some after save listener that we don't want to be executed when the system is initialized.

I'm trying to use this, but it didn't work because it always return true

Registry.getCurrentTenantNoFallback().getJaloConnection().isSystemInitialized()

I'm trying to set session attribute in InitialDataSystemSetup and in the after save listener I would check if that attribute is null or not, and the result is always null.

So, how can we detect that the system is initializing?

Accepted Solutions (0)

Answers (2)

Answers (2)

adiputera
Active Participant

Okay, so I ended up using a property that I set in the backend (not in the local.properties)

In the InitialDataSystemSetup, at the beginning of the createProjectData method, I set the property by executing these code:

Config.setParameter(INIT_SYSTEM, "true");

Then in the AfterSaveListener, I just need to check if that parameter is null or not

if (null == Config.getParameter(INIT_SYSTEM))

If the parameter is null, it indicates that the system is not initializing. It's not perfect, but it does its job.

adamreisberg
Active Participant

Hi adiputera

Given that initialization only should happen once (1x) during the lifecycle of a SAP Commerce project, my recommendation is to add a configuration parameter that is changed when the application is initializing vs. when the application is running.

You would need to customize the custom After Save Event Listener to read the value of the property, and act on that

For setting the property, while initializing (or updating) in CCV2, you can configure through the hcs_admin (e.g. the presence or absence of said property).

If this solution does not work (and you need to use the After Save Event listener) observe the architecture of the Integration API module Webhook integration (which responds to After Save Events). This may give some additional direction on how you can design your solution.

adiputera
Active Participant
0 Kudos

Thanks adamreisberg-acn

In production, yes, it should happen only once

In local, initialization might needed when we mess up something while developing some feature.

I was thinking also about creating a property, but manual changing of the value is needed.