Consumer
📌 Purpose
🔧 Class: CampaignExecutionConsumer
CampaignExecutionConsumer@Component
public class CampaignExecutionConsumer {
@Autowired
private CampaignExecutionRepository executionRepository;
@Autowired
private CampaignExecutionService executionService;
@Autowired
private TransactionTemplateBuilder ttb;
@SchedulerLock(name = "CampaignExecutionConsumer_consume", lockAtMostFor = "PT5M", lockAtLeastFor = "PT30S")
@Scheduled(initialDelay = 300_000, fixedDelayString = "${campaign.execution.consumer.fixedDelay}")
public void consume() {
executionRepository.findNewExecutionId()
.ifPresent(id -> {
ttb.requiresNew().executeWithoutResult(s -> {
CampaignExecution execution = executionRepository.getSync(id);
if (execution.getStatus() == CampaignExecutionStatus.NEW) {
executionService.runExecution(execution);
}
});
});
}
}🔁 Execution Frequency and Safety
⚙️ Core Logic
💥 Error Handling
🧪 Example Behavior
📌 Summary
Last updated
Was this helpful?