routing) {
super.setupEventRouting(routing);
- routing.route(OpenOfficeDocumentUploaded.class,
- (message, context) -> withId(message.getId()));
+ routing.route(OpenOfficeDocumentUploaded.class, (message, context) -> route(message));
+ }
+
+ /**
+ * Routes an external event to the instances of {@link DocumentAggregate}.
+ *
+ * This method includes an explicit call to repository's {@code find(..)} method.
+ * This is done to ensure that even in multi-tenant environment such a call
+ * is available, meaning that the {@code TenantId} is present in scope
+ * of runtime execution context.
+ *
+ *
Corresponding tests are available
+ * in {@link io.spine.server.integration.IntegrationBrokerTest IntegrationBrokerTest}.
+ *
+ * @param event
+ * event to route
+ * @return set of identifiers
+ */
+ private Set route(OpenOfficeDocumentUploaded event) {
+ DocumentId id = event.getId();
+ Optional aggregate = find(id);
+ if (!aggregate.isPresent()) {
+ _debug().log("`Document` aggregate is not found by ID `%s`. " +
+ "Creating a new instance.", id);
+ }
+ return withId(id);
}
}
diff --git a/version.gradle.kts b/version.gradle.kts
index 3f8b9f046e6..787f1cf6b9a 100644
--- a/version.gradle.kts
+++ b/version.gradle.kts
@@ -34,7 +34,7 @@
/**
* Version of this library.
*/
-val coreJava = "1.9.0-SNAPSHOT.8"
+val coreJava = "1.9.0-SNAPSHOT.9"
/**
* Versions of the Spine libraries that `core-java` depends on.