Run Schedule only in production environment

Asked

Viewed 79 times

1

I have a procedure that runs every beginning of month to reset password of inactive users. This procedure changes the user’s password and sends an email notifying the new password.

However, I have different environments ( local, homologation and production ) and I want this to be performed only in production. I thought to put a parameter in the parametro_system table and check if the environment is production to be able to perform the procedure, but periodically the production base Restore is done in other environments and this may not solve my problem.

Someone has a better solution for this?

Follows the code:

@Schedule(dayOfMonth="1", hour="2", persistent=false)
    private void execute() throws BusinessException {
        resetarSenhas();
    }
  • It can depend a lot on the frameworks package you are using. How do you configure this environment? Through spring profiles for example? If this is the case take a look at this answer https://stackoverflow.com/questions/18406713/how-to-conditionally-enable-or-disable-scheduled-jobs-in-spring

  • The system does not use a framework like Spring. But token control is performed via JWT. Requests are via Rest.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.