Hi,
could someone, maybe you Allard shortly explain if it is an option to use the domain model as read/view model for external client requests please. I tried this with Axon and can’t get it working because of UnitOfWork related exceptions.
For example in scala:
…
val repository = new EventSourcingRepositoryOrder;
repository.setEventStore(eventStore)
repository.setEventBus(eventBus);
repository.setSnapshotterTrigger(snapshotterTrigger)
AnnotationCommandHandlerAdapter.subscribe(new OrderCommandHandler(repository), commandBus)
val callback = new VoidCallback {
override def onSuccess(): Unit = {
}
override def onFailure(t: Throwable): Unit = {
throw t
}
}
val id = UUID.randomUUID().toString()
commandGateway.send(CreateOrder(IdRev(id, 0)), callback)
val uow = DefaultUnitOfWork.startAndGet()
try {
val order = repository.load(id)
println("order: " + order)
uow.commit();
} catch {
case e: Exception => {
uow.rollback(e);
}
}
While uow.commit() i get
java.lang.IllegalStateException: Could not clear this UnitOfWork. It is not the active one.
So my question is what i’m doing wrong here? If it don’t start an own UOW before asking the repository i get
java.lang.IllegalStateException: No UnitOfWork is currently started for this thread.
Thanks
Marcus