-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
102 changed files
with
2,643 additions
and
1,466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
...kpool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/task/EngineTaskCommandSorter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/task/ExternalCommandHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package io.holunda.polyflow.taskpool.core.task | ||
|
||
import io.holunda.camunda.taskpool.api.task.BatchCommand | ||
import io.holunda.camunda.taskpool.api.task.CreateTaskCommand | ||
import io.holunda.polyflow.taskpool.core.ifPresentOrElse | ||
import io.holunda.polyflow.taskpool.core.loadOptional | ||
import org.axonframework.commandhandling.CommandHandler | ||
import org.axonframework.commandhandling.GenericCommandMessage | ||
import org.axonframework.eventsourcing.EventSourcingRepository | ||
import org.axonframework.messaging.MetaData | ||
import org.axonframework.messaging.unitofwork.BatchingUnitOfWork | ||
import org.axonframework.messaging.unitofwork.DefaultUnitOfWork | ||
import org.springframework.context.annotation.Lazy | ||
import org.springframework.stereotype.Component | ||
|
||
/** | ||
* Handler allowing to re-submit a create command for already existing task. | ||
*/ | ||
@Component | ||
class ExternalCommandHandler( | ||
@Lazy | ||
val eventSourcingRepository: EventSourcingRepository<TaskAggregate> | ||
) { | ||
|
||
/** | ||
* Create a new aggregate (default) or load existing and replay the creation command if already there. | ||
*/ | ||
@CommandHandler | ||
fun create(command: CreateTaskCommand, metadata: MetaData) { | ||
eventSourcingRepository.loadOptional(command.id).ifPresentOrElse( | ||
presentConsumer = { aggregate -> aggregate.handle(GenericCommandMessage(command, metadata)) }, | ||
missingCallback = { eventSourcingRepository.newInstance { TaskAggregate() }.handle(GenericCommandMessage(command, metadata)) } | ||
) | ||
} | ||
|
||
/** | ||
* Delivers a batch. | ||
* @param batch batch command. | ||
*/ | ||
@CommandHandler | ||
fun handleBatch(batch: BatchCommand, metadata: MetaData) { | ||
eventSourcingRepository.loadOptional(batch.id).ifPresentOrElse( | ||
presentConsumer = { aggregate -> | ||
aggregate | ||
.apply { | ||
batch.commands.forEach { command -> | ||
val message = GenericCommandMessage(command, metadata) | ||
val handling = { handle(message) } | ||
val uow = DefaultUnitOfWork.startAndGet(message) | ||
uow.executeWithResult(handling) | ||
} | ||
} | ||
}, | ||
missingCallback = { | ||
eventSourcingRepository.newInstance { TaskAggregate() } | ||
.apply { batch.commands.forEach { command -> handle(GenericCommandMessage(command, metadata)) } } | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.