Spring Boot· 35 min

Spring Boot Jobs, Files, and Async Work

Design scheduled jobs, file upload flows, asynchronous work, timeouts, and operational safeguards.

Java interview lesson
Question 21 · Not reviewed

Spring Boot · operations

Can you explain this clearly in an interview?

Use the strong answer as your reference, explain it aloud in your own words, then choose how soon you want to review it again.

Interview prompt

Spring Boot Jobs, Files, and Async Work

Explain it aloud in your own words

Strong answer

Scheduled, file, and asynchronous workflows need explicit limits and failure handling. Define whether work is at-most-once or retryable, make operations idempotent, bound concurrency, and record enough state to recover after a restart.

Key points

  • A scheduled job may run twice in a cluster unless coordination is designed.
  • Large file uploads need size, content, storage, and virus-scanning policies.
  • Async work needs queue capacity, timeout, retry, and dead-letter behavior.
  • Never use an unbounded executor for production traffic.

Interviewer looks for

Describe how the job behaves after a crash, duplicate delivery, timeout, or partial success.

Java example

1@Scheduled(fixedDelayString = "${jobs.cleanup-delay-ms}")
2void cleanup() {
3  // Load a bounded batch, process idempotently, and persist a checkpoint.
4}

Topic interview questions

Revise this topic like an interviewer

These questions are tied to this lesson. Read each question aloud, then compare your explanation with the strong answer.

5 questions
Q1Intermediate

Why can a scheduled job run more than once in a cluster?

Strong answer

Each application instance may trigger the schedule independently. Use a distributed lock, a single worker, or a coordination mechanism, and make the job safe if duplicate execution still occurs.

Q2Intermediate

How should retryable background work be designed?

Strong answer

Make the operation idempotent, classify retryable versus permanent failures, use bounded exponential backoff, record attempts, and send exhausted messages to a dead-letter or review path.

Q3Intermediate

How are exceptions handled in asynchronous work?

Strong answer

An exception may be stored in a Future or CompletableFuture rather than thrown on the submitting thread. Observe and handle completion failures explicitly, and include logging, metrics, and a retry or compensation policy.

Q4Intermediate

What controls belong in a file-upload flow?

Strong answer

Set size and content limits, validate the actual content type, stream large files, store them outside the application process, scan when required, and authorize access to the resulting object.

Q5Intermediate

Why should async executors be bounded?

Strong answer

An unbounded executor can accept work faster than downstream systems can process it, causing memory growth and latency collapse. Capacity, queueing, rejection, timeouts, and shutdown behavior should be explicit.

How well do you know this?

Your review choice is saved locally and synced to your learner profile when signed in.