Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Enable IntegrationBroker dispatch events regardless of registration order of subscribing and publishing BCs #1408

Merged
merged 68 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
272da03
Make `BoundedContext.Internal` register*() methods chainable
yevhenii-nadtochii Oct 28, 2021
44bb506
Fix caught typos
yevhenii-nadtochii Oct 28, 2021
92494ee
Create `ExternalMessagesSourceAvailable` proto message
yevhenii-nadtochii Oct 28, 2021
d7aded9
Make `BlackBox` implement `Closeable`
yevhenii-nadtochii Oct 28, 2021
58ecd0e
Make entity type of `EmptyAggregate` to `AGGREGATE`
yevhenii-nadtochii Oct 28, 2021
7dcf2d1
Implement new proto messages for IntegrationBrokerTest
yevhenii-nadtochii Oct 28, 2021
d56b47b
Delete no longer used proto messages of `IntegrationBrokerTest`
yevhenii-nadtochii Oct 28, 2021
6d17094
Re-write tests of `IntegrationBroker` with `BlackBox`
yevhenii-nadtochii Oct 28, 2021
fac9724
Make `IntegrationBroker` emit `ExternalMessagesSourceAvailable` on it…
yevhenii-nadtochii Oct 28, 2021
59e5291
Bump the version
yevhenii-nadtochii Oct 28, 2021
bdc52dd
Fix EOF
yevhenii-nadtochii Oct 28, 2021
1be6cb6
Use `StringValue.of()` instead of builder
yevhenii-nadtochii Nov 1, 2021
5f18ff4
Fix `@linkplain`
yevhenii-nadtochii Nov 1, 2021
7205587
Remove the dead code.
armiol Nov 2, 2021
cd27c01
Reformat the code to fit the max page width.
armiol Nov 2, 2021
cc24abb
Shorten the method name.
armiol Nov 2, 2021
3809a93
Shorten the expression.
armiol Nov 2, 2021
27dacbe
Extract and document the anonymous type.
armiol Nov 2, 2021
d6a4277
Fix the indentation in the Javadoc section.
armiol Nov 2, 2021
c35aca6
Rename components and messages to reflect the idea of the described p…
armiol Nov 8, 2021
78f320b
Continue renaming and shaping things to get closer to the real life.
armiol Nov 9, 2021
141a820
Avoid the imports just for the Javadoc.
armiol Nov 9, 2021
da83dde
Turn off the Integration Broker for the System context.
armiol Nov 9, 2021
d7612d5
Ignore the integration messages if the receiver is the same as the se…
armiol Nov 9, 2021
1e5db4e
Continue to simplify and document.
armiol Nov 9, 2021
4459e31
Remove an unused method. Rename some params.
armiol Nov 9, 2021
7cb69dd
Move rename and move some static methods.
armiol Nov 9, 2021
5d5002d
Re-enable the integration broker for the System context.
armiol Nov 10, 2021
a18b7cf
Start moving things to the standalone exchanges.
armiol Nov 10, 2021
9d30efb
Extract the `EventsExchange`. Rename the one exchanging wanted events…
armiol Nov 11, 2021
11ffda9
Remove the `Channels` utility after moving its functionality pieces t…
armiol Nov 11, 2021
731f6ed
Check the `config` for `null`. Remove an obsolete suppression.
armiol Nov 11, 2021
83fa205
Improve the docs.
armiol Nov 11, 2021
32fe5d3
Adjust the doc formatting.
armiol Nov 11, 2021
e91b115
Improve the wording.
armiol Nov 11, 2021
1eecfc2
Rename the variable.
armiol Nov 11, 2021
b818b42
Improve the wording.
armiol Nov 11, 2021
a8d9a00
Document the fields.
armiol Nov 11, 2021
3e339d2
Document the method.
armiol Nov 11, 2021
3e6c2ae
Improve the documentation.
armiol Nov 11, 2021
36ec36e
Improve the documentation.
armiol Nov 11, 2021
91297ab
Capitalize the term.
armiol Nov 11, 2021
7d2a625
Capitalize the term.
armiol Nov 11, 2021
791ffc9
Improve the docs.
armiol Nov 11, 2021
d852087
Add the backticks.
armiol Nov 11, 2021
bdc351b
Remove the unused code.
armiol Nov 11, 2021
808f5fd
Improve the documentation.
armiol Nov 11, 2021
ded8a4b
Reduce the visibility.
armiol Nov 11, 2021
2440985
Merge remote-tracking branch 'origin/master' into integration-broker-…
armiol Nov 11, 2021
d276ca4
Use `mc-java` of a proper version.
armiol Nov 11, 2021
7460d07
Update to the latest `config`.
armiol Nov 11, 2021
87a1894
Bump own version. Use the latest `mc-java` as well.
armiol Nov 11, 2021
79a2e04
Migrate to the new API of `McJavaOptions`.
armiol Nov 11, 2021
ae3e9d8
Migrate `test-artifacts`.
armiol Nov 11, 2021
ce2912a
Update the license reports.
armiol Nov 11, 2021
7e46e7e
Add the alt text to links.
armiol Nov 12, 2021
99f744b
Adjust the code layout.
armiol Nov 12, 2021
35a23b4
Use `forEach`.
armiol Nov 12, 2021
0a921d5
Mark the `final` class as such.
armiol Nov 12, 2021
9fd15f6
Avoid using `@Internal` for the package-private API.
armiol Nov 12, 2021
a81e5f3
Remove the excessive check.
armiol Nov 12, 2021
f4ba93b
Fix a typo.
armiol Nov 12, 2021
9e9c995
Shorten the description.
armiol Nov 12, 2021
8bbf1e7
Reduce the visibility.
armiol Nov 12, 2021
78e8df8
Hide the utility as it's now never used from outside.
armiol Nov 12, 2021
5844f4a
Use a proper tag for the alt text.
armiol Nov 12, 2021
ff88d9a
Suppress the warning.
armiol Nov 12, 2021
419a37e
Kill the unused exception.
armiol Nov 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ buildscript {
val kotlinVersion = io.spine.internal.dependency.Kotlin.version
val spineBaseVersion: String by extra
val spineTimeVersion: String by extra
val mcJavaVersion: String by extra

dependencies {
classpath("io.spine.tools:spine-mc-java:$spineBaseVersion")
classpath("io.spine.tools:spine-mc-java:$mcJavaVersion")
}

io.spine.internal.gradle.doForceVersions(configurations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ package io.spine.internal.dependency
// https://github.com/Kotlin
object Kotlin {
@Suppress("MemberVisibilityCanBePrivate") // used directly from outside
const val version = "1.5.30"
const val version = "1.5.31"
const val reflect = "org.jetbrains.kotlin:kotlin-reflect:${version}"
const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib:${version}"
const val stdLibCommon = "org.jetbrains.kotlin:kotlin-stdlib-common:${version}"
Expand Down
8 changes: 3 additions & 5 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import io.spine.internal.dependency.Grpc
import io.spine.internal.gradle.Scripts
import io.spine.internal.gradle.testing.exposeTestArtifacts

val spineBaseVersion: String by extra

Expand All @@ -43,9 +44,6 @@ dependencies {
testImplementation(project(":testutil-client"))
testImplementation(project(path = ":core", configuration = "testArtifacts"))
}

apply {
with(Scripts) {
from(testArtifacts(project))
}
java {
exposeTestArtifacts()
}
8 changes: 3 additions & 5 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

import io.spine.internal.gradle.Scripts
import io.spine.internal.gradle.testing.exposeTestArtifacts

val spineBaseTypesVersion: String by extra
val spineTimeVersion: String by extra
Expand All @@ -51,9 +52,6 @@ modelCompiler {
}
}
}

apply {
with(Scripts) {
from(testArtifacts(project))
}
java {
exposeTestArtifacts()
}
320 changes: 160 additions & 160 deletions license-report.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import io.spine.model.CommandHandlers;
import io.spine.model.assemble.AssignLookup;
import io.spine.tools.gradle.SpinePlugin;
import io.spine.tools.mc.java.gradle.McJavaExtension;
import io.spine.tools.mc.java.gradle.McJavaOptions;
import io.spine.tools.type.MoreKnownTypes;
import org.gradle.api.Action;
import org.gradle.api.Project;
Expand All @@ -46,7 +46,6 @@

import static io.spine.tools.gradle.JavaTaskName.classes;
import static io.spine.tools.gradle.JavaTaskName.compileJava;
import static io.spine.tools.mc.java.gradle.McJavaExtension.getMainDescriptorSetFile;
import static io.spine.tools.mc.java.gradle.plugins.ModelVerifierTaskName.verifyModel;
import static java.nio.file.Files.exists;
import static java.nio.file.Files.newInputStream;
Expand Down Expand Up @@ -118,9 +117,9 @@ public void execute(Task task) {
}

private void extendKnownTypes(Project project) {
String pluginExtensionName = McJavaExtension.name();
String pluginExtensionName = McJavaOptions.name();
if (project.getExtensions().findByName(pluginExtensionName) != null) {
File descriptorFile = getMainDescriptorSetFile(project);
File descriptorFile = McJavaOptions.descriptorSetFileOf(project, true);
tryExtend(descriptorFile);
} else {
_warn().log(
Expand Down
20 changes: 10 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
-->
<groupId>io.spine</groupId>
<artifactId>spine-core-java</artifactId>
<version>2.0.0-SNAPSHOT.75</version>
<version>2.0.0-SNAPSHOT.76</version>

<inceptionYear>2015</inceptionYear>

Expand Down Expand Up @@ -80,13 +80,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-mc-java</artifactId>
<version>2.0.0-SNAPSHOT.74</version>
<version>2.0.0-SNAPSHOT.76</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-mc-java-base</artifactId>
<version>2.0.0-SNAPSHOT.74</version>
<version>2.0.0-SNAPSHOT.76</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -104,13 +104,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.5.30</version>
<version>1.5.31</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.5.30</version>
<version>1.5.31</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -201,13 +201,13 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-mc-java-checks</artifactId>
<version>2.0.0-SNAPSHOT.75</version>
<version>2.0.0-SNAPSHOT.76</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.spine.tools</groupId>
<artifactId>spine-mc-java-protoc</artifactId>
<version>2.0.0-SNAPSHOT.75</version>
<version>2.0.0-SNAPSHOT.76</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
Expand All @@ -227,17 +227,17 @@ all modules and does not describe the project structure per-subproject.
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-compiler-embeddable</artifactId>
<version>1.5.30</version>
<version>1.5.31</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-klib-commonizer-embeddable</artifactId>
<version>1.5.30</version>
<version>1.5.31</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-scripting-compiler-embeddable</artifactId>
<version>1.5.30</version>
<version>1.5.31</version>
</dependency>
</dependencies>

Expand Down
19 changes: 14 additions & 5 deletions server/src/main/java/io/spine/server/BoundedContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
package io.spine.server;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.spine.annotation.Internal;
import io.spine.base.EntityState;
import io.spine.core.BoundedContextName;
Expand Down Expand Up @@ -135,7 +136,6 @@ protected BoundedContext(BoundedContextBuilder builder) {
this.eventBus = builder.buildEventBus(this);
this.stand = builder.stand();
this.tenantIndex = builder.buildTenantIndex();

this.broker = new IntegrationBroker();
this.commandBus = builder.buildCommandBus();
this.importBus = buildImportBus(tenantIndex);
Expand Down Expand Up @@ -480,7 +480,7 @@ public final InternalAccess internalAccess() {
* Provides access to features of {@link BoundedContext} used internally by the framework.
*/
@Internal
public class InternalAccess {
public final class InternalAccess {

/** Prevents instantiation from outside. */
private InternalAccess() {
Expand All @@ -489,28 +489,37 @@ private InternalAccess() {
/**
* Registers the passed repository.
*
* @return this instance of {@code InternalAccess} for call chaining
* @see BoundedContext#register(Repository)
*/
public void register(Repository<?, ?> repository) {
@CanIgnoreReturnValue
public InternalAccess register(Repository<?, ?> repository) {
self().register(checkNotNull(repository));
return this;
}

/**
* Registers the passed command dispatcher.
*
* @return this instance of {@code InternalAccess} for call chaining
* @see BoundedContext#registerCommandDispatcher(CommandDispatcher)
*/
public void registerCommandDispatcher(CommandDispatcher dispatcher) {
@CanIgnoreReturnValue
public InternalAccess registerCommandDispatcher(CommandDispatcher dispatcher) {
self().registerCommandDispatcher(checkNotNull(dispatcher));
return this;
}

/**
* Registers the passed event dispatcher.
*
* @return this instance of {@code InternalAccess} for call chaining
* @see BoundedContext#registerEventDispatcher(EventDispatcher)
*/
public void registerEventDispatcher(EventDispatcher dispatcher) {
@CanIgnoreReturnValue
public InternalAccess registerEventDispatcher(EventDispatcher dispatcher) {
self().registerEventDispatcher(dispatcher);
return this;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import io.spine.server.event.EventBus;
import io.spine.server.event.EventDispatcher;
import io.spine.server.event.EventEnricher;
import io.spine.server.integration.IntegrationBroker;
import io.spine.server.stand.Stand;
import io.spine.server.tenant.TenantIndex;
import io.spine.server.type.CommandEnvelope;
Expand Down Expand Up @@ -90,7 +89,7 @@ public final class BoundedContextBuilder implements Logging {

/**
* Event dispatchers to be registered with the context {@link EventBus} and/or
* {@link IntegrationBroker} after the Bounded Context creation.
* {@link io.spine.server.integration.IntegrationBroker} after the Bounded Context creation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a short name of the class following the fully-qualified name in the link, please?

*/
private final Collection<EventDispatcher> eventDispatchers = new ArrayList<>();

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/io/spine/server/ContextAware.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import static com.google.common.base.Preconditions.checkState;

/**
* An structural part of a Bounded Context which is aware of the other parts.
* A structural part of a Bounded Context which is aware of the other parts.
*/
@Internal
public interface ContextAware {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
import static io.spine.util.Exceptions.newIllegalStateException;

/**
* Base routines for the {@linkplain Subscriber#addObserver(StreamObserver)}
* subscriber observers}.
* Base routines for the {@linkplain Subscriber#addObserver(StreamObserver) subscriber observers}.
*/
@SPI
public abstract class AbstractChannelObserver implements StreamObserver<ExternalMessage>, Logging {
Expand All @@ -50,9 +49,18 @@ public abstract class AbstractChannelObserver implements StreamObserver<External
private final Class<? extends Message> messageClass;
private final AtomicBoolean completed = new AtomicBoolean(false);

protected AbstractChannelObserver(BoundedContextName boundedContextName,
/**
* Creates a new instance of the observer.
*
* @param context
* the name of the Bounded Context in which the created observer exists
* @param messageClass
* the type of the observed messages, which are transferred wrapped
* into {@code ExternalMessage}
*/
protected AbstractChannelObserver(BoundedContextName context,
Class<? extends Message> messageClass) {
this.boundedContextName = boundedContextName;
this.boundedContextName = context;
this.messageClass = messageClass;
}

Expand Down Expand Up @@ -88,17 +96,26 @@ public final void onNext(ExternalMessage message) {
checkNotNull(message);
checkState(!completed.get(),
"Channel %s received message (%s[%s]) despite being closed.",
message.getClass().getName(),
message.getOriginalMessage().getTypeUrl());
message.getClass()
.getName(),
message.getOriginalMessage()
.getTypeUrl());
BoundedContextName source = message.getBoundedContextName();
boolean sameContext = boundedContextName.equals(source)
|| boundedContextName.isSystemOf(source)
|| source.isSystemOf(boundedContextName);
|| boundedContextName.isSystemOf(source)
|| source.isSystemOf(boundedContextName);
if (!sameContext) {
handle(message);
}
}

/**
* Returns the name of the Bounded Context in scope of which this observer exists.
*/
protected final BoundedContextName contextName() {
return boundedContextName;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Loading