Class DbSchedulerEventScheduler.Builder
java.lang.Object
org.axonframework.eventhandling.scheduling.dbscheduler.DbSchedulerEventScheduler.Builder
- Enclosing class:
DbSchedulerEventScheduler
Builder class to instantiate a
DbSchedulerEventScheduler.
The TransactionManager is defaulted to a NoTransactionManager. The useBinaryPojo and
startScheduler are defaulted to true.
The Scheduler, Serializer and EventBus are hard requirements and as such should be
provided.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aDbSchedulerEventScheduleras specified through this Builder.Sets theEventBusused to publish events on once the schedule has been met.scheduler(com.github.kagkarlsson.scheduler.Scheduler scheduler) Sets theSchedulerused for scheduling and triggering purposes of the events.serializer(Serializer serializer) startScheduler(boolean startScheduler) Sets whether to start theSchedulerusing theLifecycle, or to never start the scheduler from this component instead.stopScheduler(boolean stopScheduler) Sets whether to stop theSchedulerusing theLifecycle, or to never stop the scheduler from this component instead.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to build transactions and ties them on event publication.useBinaryPojo(boolean useBinaryPojo) Sets whether to use a pojo optimized for size,DbSchedulerBinaryEventData, compared to a pojo optimized for readability,DbSchedulerEventScheduler.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
scheduler
public DbSchedulerEventScheduler.Builder scheduler(com.github.kagkarlsson.scheduler.Scheduler scheduler) Sets theSchedulerused for scheduling and triggering purposes of the events. It should have either theDbSchedulerEventScheduler.binaryTask(Supplier)or theDbSchedulerEventScheduler.humanReadableTask(Supplier)from this class as one of its tasks to work. Which one depends on the setting ofuseBinaryPojo. Whentrue, useDbSchedulerEventScheduler.binaryTask(Supplier)elseDbSchedulerEventScheduler.humanReadableTask(Supplier). Depending on you application, you can manage when to start the scheduler, or leavestartSchedulerto true, to start it via theLifecycle.- Parameters:
scheduler- aSchedulerused for scheduling and triggering purposes of the events- Returns:
- the current Builder instance, for fluent interfacing
-
serializer
- Parameters:
serializer- aSerializerused to de-/serialize thepayload, andMetaData.- Returns:
- the current Builder instance, for fluent interfacing
-
transactionManager
Sets theTransactionManagerused to build transactions and ties them on event publication. Defaults to aNoTransactionManager.- Parameters:
transactionManager- aTransactionManagerused to build transactions and ties them on event publication- Returns:
- the current Builder instance, for fluent interfacing
-
eventBus
Sets theEventBusused to publish events on once the schedule has been met.- Parameters:
eventBus- aEventBusused to publish events on once the schedule has been met- Returns:
- the current Builder instance, for fluent interfacing
-
useBinaryPojo
Sets whether to use a pojo optimized for size,DbSchedulerBinaryEventData, compared to a pojo optimized for readability,DbSchedulerEventScheduler.- Parameters:
useBinaryPojo- abooleanto determine whether to use a binary format.- Returns:
- the current Builder instance, for fluent interfacing
-
startScheduler
Sets whether to start theSchedulerusing theLifecycle, or to never start the scheduler from this component instead. Defaults totrue.- Parameters:
startScheduler- abooleanto determine whether to start the scheduler.- Returns:
- the current Builder instance, for fluent interfacing
-
stopScheduler
Sets whether to stop theSchedulerusing theLifecycle, or to never stop the scheduler from this component instead. Defaults totrue.- Parameters:
stopScheduler- abooleanto determine whether to stop the scheduler.- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aDbSchedulerEventScheduleras specified through this Builder.- Returns:
- a
DbSchedulerEventScheduleras specified through this Builder
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-