-
Notifications
You must be signed in to change notification settings - Fork 12
Integration Bus #580
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
Merged
Merged
Integration Bus #580
Conversation
This file contains hidden or 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
…her` concept. Use `Ack` instead of `IsSent`: handle the renaming.
Define the basic communication protocol.
# Conflicts: # core/src/main/java/io/spine/core/EventClass.java # core/src/main/java/io/spine/core/RejectionClass.java # server/src/main/java/io/spine/server/BoundedContext.java # server/src/main/java/io/spine/server/entity/EventDispatchingRepository.java # server/src/main/java/io/spine/server/outbus/CommandOutputBus.java # server/src/main/java/io/spine/server/projection/ProjectionRepository.java # server/src/main/java/io/spine/server/reflect/EventSubscriberMethod.java # server/src/main/java/io/spine/server/reflect/MethodMap.java # server/src/main/java/io/spine/server/rejection/DispatcherRejectionDelivery.java # server/src/test/java/io/spine/server/reflect/EventSubscriberMethodShould.java
…geType` messages received (identify the subscribers in a unique way for that).
Use this property to route messages between `IntegrationBus` instances.
the local bus subscriptions upon `RequestedMessageTypes` message handling.
# Conflicts: # core/src/main/java/io/spine/core/Events.java # server/src/main/java/io/spine/server/reflect/EventSubscriberMethod.java
…grationBus` to `EventBus` and `RejectionBus`. Add an `external` attribute to `Rejection` message — to comply the adapter contract.
…e top-level class to ease code readability and improve structure.
Address `weather` - > `whether` typos in the related classes.
# Conflicts: # server/src/main/java/io/spine/server/event/EventReactorMethod.java # server/src/main/java/io/spine/server/event/EventSubscriberMethod.java # server/src/main/java/io/spine/server/model/MessageHandlerMap.java # server/src/main/java/io/spine/server/procman/ProcessManager.java # server/src/main/java/io/spine/server/procman/ProcessManagerRepository.java # server/src/main/java/io/spine/server/projection/Projection.java # server/src/main/java/io/spine/server/projection/ProjectionRepository.java # server/src/main/java/io/spine/server/reflect/MethodRegistry.java # server/src/main/java/io/spine/server/rejection/RejectionSubscriberMethod.java # server/src/test/java/io/spine/server/commandbus/AbstractCommandBusTestSuite.java
…odel` classes; cache them to use more effectively.
…re tests for `IntegrationBus` `@React`ing.
@alexander-yevsyukov comments are addressed. PTAL again. |
…o emphasize the design intention.
… and adjust Javadocs accordingly. Make those `final`.
alexander-yevsyukov
approved these changes
Sep 15, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces
IntegrationBus
and ability to exchange messages betweenBoundedContext
s.Highlights:
IntegrationBus
along withTransportFactory
are introduced and represent a mechanism of inter-BoundedContext
communication. EachBoundedContext
may produce events and rejections in which other contexts are interested (the latter are downstream in this case). The messages of interest are brought to their subscribers/reactors via a customizableTransport
, inspired by Publish-Subscribe messaging systems.React(external = true)
andSubscribe(external = true)
now allow to process events and rejections that are fired by another bounded context. Handler methods markedexternal
play an anticorruption layer role (see ACL pattern in "Domain-Driven Design" by Eric Evans and "Implementing Domain-Driven Design" by Vaughn Vernon) .TransportFactory
andMessageChannel
concepts are introduced. There is also a naïve in-memory transport implementation for test purposes.In addition,
BoundedContextId
is introduced to identify bounded contexts. It is an improvement to aString
used for identification previously.IntegrationBus
This bus is available as a part of single
BoundedContext
. In a multi-component environment messages may travel across components from one bounded context to another.IntegrationBus
is always based upon some transport (see more on that below), that delivers the messages from and to it. For several bounded contexts to communicate, their integration buses have to share the transport. Typically that would be a single messaging broker.The messages from external components received by the
IntegrationBus
instance via the transport are propagated into the bounded context. They are dispatched to the subscribers and reactors marked withexternal = true
on per-message-type basis.IntegrationBus
is also responsible for publishing the messages, born within the currentBoundedContext
, to external collaborators. To do that properly, the bus listens to a special document message calledRequestForExternalMessages
, that describes the needs of other parties.E.g. bounded context
Projects
has the external event handler method in the projection as follows:Upon a registration of the corresponding repository the integration bus of
Projects
context sends out aRequestForExternalMessages
saying that anEvent
ofUserDeleted
is needed from other parties.Let's say the second bounded context is
Users
. Its integration bus will receive theRequestForExternalMessages
request sent out byProjects
. To handle it properly it will create a bridge betweenUsers
's event bus (which may eventually be transmittingUserDeleted
event) and an external transport. OnceUserDeleted
is published locally inUsers
context, it will be received by this bridge (as well as other local dispatchers), and published to the external transport.The integration bus of
Projects
context will receive theUserDeleted
external message. The event will be dispatched to the external event handler ofProjectListView
projection.TransportFactory and MessageChannel
This PR introduces an initial implementation of Publish-Subscribe Channel pattern.
The
TransportFactory
allows to create channels for outgoing messages (Publisher
s) and incoming messages (Subscriber
s). Each channel serves messages of a single type.In scope of this PR an in-memory implementation is provided, which is only suitable for the publishers and subscribers located within the same JVM. In the nearest future a Google Cloud-based implementation will be added to Spine.
The framework version is set to
0.9.65-SNAPSHOT
.To be delivered in the following PRs:
Transport
along with proper integration tests.Transport
along with proper integration tests.