CampaignService
CampaignService
The CampaignService
is responsible for managing campaigns — including manual launches and status transitions.
It acts as a facade for initiating campaign execution, including the creation of CampaignExecution
.
🔧 Method: startCampaign(Long campaignId)
startCampaign(Long campaignId)
📌 Behavior
Retrieves the
Campaign
usinggetSync(...)
— ensures the entity is up-to-date and synchronizedVerifies that the campaign is active
If the campaign is automatic, it sets the status to
SCHEDULED
(if not already)If it's a manual campaign and no execution is currently
IN_PROGRESS
, it:Creates a new
CampaignExecution
After the current transaction commits (
TransactionUtils.afterTransaction
), it launches the execution in a new transaction
🔒 Transactional Handling
The entire method is wrapped with @Transactional(rollbackFor = Throwable.class)
and uses TransactionTemplateBuilder
to ensure safe execution in an isolated transaction.
Last updated
Was this helpful?