#290 Transactions During Item Processing from an @Scheduled Method

Companies:
InfiniteSynergy
Themes:
Spring CoreTransactionsCode Review

What happens with transactions when beginProcessing() is called?

@Service
@RequiredArgsConstructor
public class ServiceA {
    private final ServiceB serviceB;

    @Scheduled(someCron)
    public void beginProcessing() {
        List<SomeObject> result = getCollectionOfSomeObjects(); // 1
        for (SomeObject item : result) {
            processSingleItem(item);
        }
    }

    public void processSingleItem(SomeObject source) {
        serviceB.updateSomeField(source, someValue);
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in