Skip to content

FINERACT-2493: New command processing - job scheduling#5903

Open
nidhiii128 wants to merge 1 commit into
apache:developfrom
nidhiii128:FINERACT-2493-update-job
Open

FINERACT-2493: New command processing - job scheduling#5903
nidhiii128 wants to merge 1 commit into
apache:developfrom
nidhiii128:FINERACT-2493-update-job

Conversation

@nidhiii128

@nidhiii128 nidhiii128 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

Migrates the "update job" REST endpoint (by jobId) from the legacy command-processing path to the new fineract-command framework.

Scope (PR 1 of 2 for FINERACT-2493)

  • New typed UpdateJobRequest / UpdateJobResponse POJOs with Jakarta Validation
  • New UpdateJobCommand and UpdateJobCommandHandler using CommandHandler<REQ, RES>
  • SchedularWritePlatformService.updateJobDetail signature changed to accept typed request
  • Change-detection logic moved from entity into service (per Aleks's guidance)
  • Hand-written JobDetailDataValidator no longer called, replaced by @AssertTrue annotations
  • Backward-compatible: existing integration tests pass unchanged

Not in this PR

  • "Update job by short-name" - deferred pending Aleks's guidance on where short-name resolution should live
  • "Execute job" migration - separate follow-up PR

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
  • Create/update unit or integration tests for verifying the changes made.
  • Follow our coding conventions.
  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "code dump". Large changes can be made in a branch, with assistance. Ask for help on the developer mailing list.

Your assigned reviewer(s) will follow our guidelines for code reviews.

@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch from 52322d5 to 9851afe Compare May 29, 2026 10:01
@Aman-Mittal

Copy link
Copy Markdown
Member

@nidhiii128 Fix that failing checks.

@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch 2 times, most recently from a1278c6 to 28d0073 Compare May 31, 2026 05:52
@Aman-Mittal Aman-Mittal requested a review from vidakovic May 31, 2026 07:01
@Aman-Mittal

Copy link
Copy Markdown
Member

@vidakovic please review

@Aman-Mittal Aman-Mittal requested a review from budaidev May 31, 2026 07:01
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UpdateJobResponse implements Serializable {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming pattern.

@Slf4j
@Component
@RequiredArgsConstructor
public class UpdateJobCommandHandler implements CommandHandler<UpdateJobRequest, UpdateJobResponse> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming pattern:

[Domain] + [Action] + "CommandHandler"

... in this case...

JobUpdateCommandHandler

@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch from 28d0073 to 0e074a5 Compare June 5, 2026 07:56
@nidhiii128

Copy link
Copy Markdown
Contributor Author

Hi @vidakovic, thank you, I've addressed all your comments:

Renamed DTOs and handlers to follow the [Domain][Action][Suffix] pattern (JobUpdateRequest, JobUpdateResponse, JobUpdateCommandHandler)
Removed the trivial @apiresponse(200) annotation
Removed @Autowired and switched to @requiredargsconstructor
Folded jobId into the request object in SchedulerJobHelper
Moved findByJobId and retrieveSchedulerDetail out of the write service — created a new ScheduledJobReadService interface in fineract-provider (since the domain types aren't accessible from fineract-core, the interface lives in fineract-provider and SchedulerJobRunnerReadServiceImpl implements it). This took a bit of investigation to get right given the module boundaries, but I think the result cleanly separates the read concerns.
Could you please take another look when you get a chance?

@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch 4 times, most recently from 7ba985c to f459d0c Compare June 5, 2026 10:29
@nidhiii128 nidhiii128 force-pushed the FINERACT-2493-update-job branch from f459d0c to 61b2f94 Compare June 5, 2026 11:54
@Aman-Mittal

Copy link
Copy Markdown
Member

@vidakovic please review again.

@vidakovic

Copy link
Copy Markdown
Contributor

@nidhiii128 @Aman-Mittal note for upcoming PRs: can you resolve the conversations that are fixed please? Makes it easier to do the reviews. Thanks.

@@ -87,6 +91,7 @@ public class SchedulerJobApiResource {
private final PlatformSecurityContext context;
private final FineractProperties fineractProperties;
private final SqlValidator sqlValidator;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that should reside in a service? Or is this validation like in Jakarta Validation of input parameters? SqlValidator is a very low level implementation detail that we shouldn't reveal in the REST layer... my 2 cents.

@@ -37,11 +37,7 @@ public interface SchedularWritePlatformService {

Long fetchMaxVersionBy(String triggerKey);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"fetch" sounds like a read service function, no? Shouldn't we move that one too to read service?


@Service
@RequiredArgsConstructor
public class SchedularWritePlatformServiceJpaRepositoryImpl implements SchedularWritePlatformService {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, how about SchedulerWritePlatformServiceJpaRepositoryImpl and SchedulerWritePlatformService?

this.dataValidator = dataValidator;
}

@Override

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read function... read service? Please move and make sure that the write service only exposes functions that change data. While we are here let's clean this stuff up even if it might not be directly related to the project. Please check the rest of the service class for similar stuff. Thanks.

}

@Override
public SchedulerDetail retriveSchedulerDetail() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, how about retrieveSchedulerDetail?

private Boolean active;

@JsonIgnore
@AssertTrue(message = "{org.apache.fineract.infrastructure.jobs.update.at-least-one-field}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, two things:

  1. Translation key: how about this pattern:

org.apache.fineract.infrastructure.job.update.assertion.at-least-one ... and below...
org.apache.fineract.infrastructure.job.update.assertion.cron-expression

This keeps things short and we have the same number of segments in both keys ("assertions" tells us already that something is validated, so we don't have to use words like "invalid" and similar). Not earth shattering differences, but keeps everything compact and concise.

  1. Did you actually provide translations for these keys? I don't see any changes in https://github.com/apache/fineract/blob/develop/fineract-validation/src/main/resources/ValidationMessages.properties; please fix.

private final SchedularWritePlatformService schedularWritePlatformService;
private final JobRegisterService jobRegisterService;

@Retry(name = "commandJobUpdate", fallbackMethod = "fallback")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the resilience configuration for this is missing? Please have a look at this here to see how this works:

. Please add missing entries for this command handler.

private final CommandDispatcher dispatcher;

@GET
@Operation(summary = "Retrieve Scheduler Jobs", operationId = "retrieveAllSchedulerJobs", description = "Returns the list of jobs.\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like authorization enforcement is missing. In the legacy code these checks are usually done by using PlatformSecurityContext; we really shouldn't, because it obscures the security configuration unnecessarily and makes it really hard if we need to investigate or audit things. So, good that it's removed here... but we have to provide the - correct - equivalent. Please see here

how to do this. And of course this needs to be done for every endpoint that is exposed by this resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants