#250 Partial Rollback During Parallel Processing
More than 100 values are passed to process. An error occurs while processing the last value in the list. Which changes are written to the database?
@Service
public class Processor {
@Transactional
public void process(List<String> items) {
if (CollectionUtils.isEmpty(items)) {
return;
}
items.parallelStream()
.forEach(this::processItem);
}
private void processItem(String item) {
// insert/update item entity in DB
}
}
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor