Hi @nikortel, and welcome to our forum!
The warn message is intended to signal users that they may be using Repository
from an unexpected piece of code.
Note that the Repository
in Axon Framework is a solution intended to be invoked by (1) Command Handlers and (2) Deadline Handlers.
Axon Framework’s annotated-model approach (read: @CommandHandler
and @DeadlineHandler
annotations on the Aggregate class) ensures you a CommandMessage
or DeadlineMessage
is in the active UnitOfWork
.
Furthermore, direct use of the Repository
from within an @CommandHandler
annotated method outside the model ensure this too, as Axon set’s a UnitOfWork
containing the message that’s being handled at all times.
If you, however, invoke the Repository
from other locations, there’s a chance that you either (1) don’t have a UnitOfWork
at all or (2) are in the scope of another type of Message
.
Scenario one may occur when you are, for example, invoking the Repository
directly from a POST endpoint. So, without having dispatched a command/event/query or without having manually set a UnitOfWork
.
Scenario two, the one I assume you are in, occurs whenever you invoke the Repository
from an @EventHandler
, @QueryHandler
, or @ExceptionHandler
(as shown in this issue, which led to the introduction of the WARN-level log message) annotated method.
So, to conclude, as Axon Framework expects invocations of the Repository
to occur through command and deadline handlers, we warn the user when this is not the case.
As in your scenario the logging states a GenericTrackedDomainEventMessage
is present, that to me suggests your code invokes the Repository
within an @EventHandler
annotated method.
Although I don’t know the full extend of your application, I do want to point out that this is thus not the default behavior of Axon Framework (hence the logging. The Repository
and it’s aggregates are used for decision-making logic, through command dispatching. It being invoked in an event handler suggests it may be used to query the state of the aggregate, which is typically not the purpose of the Command Model.
Granted, if you and the team decided against the combination of CQRS and DDD (in short, a dedicated domain model for command validation), there isn’t anything wrong.
If you do prefer to use the combination of DDD and CQRS by the book, I would suggest to not query the command model Repository
directly, every.
By the way, I am making an assumption that you are directly invoking the Repository
in an @EventHandler
annotated method. If that’s not the case, we need to investigate further.
I hope this clarifies things for you, @nikortel!