GH-869 - Polishing.

Tweak header population to use the raw routing target. Expand test case to make sure it's retained as message header.
This commit is contained in:
Oliver Drotbohm
2024-10-13 17:28:01 +02:00
parent 41aad245d4
commit a8835b211b
8 changed files with 45 additions and 24 deletions

View File

@@ -167,6 +167,7 @@ a|* `spring-modulith-docs`
|`spring-modulith-events-jms`|`runtime`|Event externalization support for JMS.
|`spring-modulith-events-jpa`|`runtime`|A JPA-based implementation of the `EventPublicationRegistry`.
|`spring-modulith-events-kafka`|`runtime`|Event externalization support for Kafka.
|`spring-modulith-events-messaging`|`runtime`|Event externalization support into Spring Messaging ``MessageChannel``s.
|`spring-modulith-events-mongodb`|`runtime`|A MongoDB-based implementation of the `EventPublicationRegistry`.
|`spring-modulith-events-neo4j`|`runtime`|A Neo4j-based implementation of the `EventPublicationRegistry`.
|`spring-modulith-junit`|`test`|Test execution optimizations based on the application module structure. Find more details xref:testing.adoc#change-aware-test-execution[here].

View File

@@ -7,6 +7,7 @@ To keep application modules as decoupled as possible from each other, their prim
This avoids the originating module to know about all potentially interested parties, which is a key aspect to enable application module integration testing (see xref:testing.adoc[Integration Testing Application Modules]).
Often we will find application components defined like this:
[tabs]
======
Java::
@@ -124,6 +125,7 @@ class InventoryManagement {
}
----
======
This now effectively decouples the original transaction from the execution of the listener.
While this avoids the expansion of the original business transaction, it also creates a risk: if the listener fails for whatever reason, the event publication is lost, unless each listener actually implements its own safety net.
Even worse, that doesn't even fully work, as the system might fail before the method is even invoked.
@@ -212,7 +214,9 @@ image::event-publication-registry-end.png[]
[[publication-registry.starters]]
=== Spring Boot Event Registry Starters
Using the transactional event publication log requires a combination of artifacts added to your application. To ease that task, Spring Modulith provides starter POMs that are centered around the <<publication-registry.publication-repositories, persistence technology>> to be used and default to the Jackson-based <<publication-registry.serialization, EventSerializer>> implementation. The following starters are available:
Using the transactional event publication log requires a combination of artifacts added to your application.
To ease that task, Spring Modulith provides starter POMs that are centered around the <<publication-registry.publication-repositories, persistence technology>> to be used and default to the Jackson-based <<publication-registry.serialization, EventSerializer>> implementation.
The following starters are available:
[%header,cols="1,3,6"]
|===
@@ -306,6 +310,7 @@ Spring Modulith provides a Jackson-based JSON implementation through the `spring
[[publication-registry.customize-publication-date]]
=== Customizing the Event Publication Date
By default, the Event Publication Registry will use the date returned by the `Clock.systemUTC()` as event publication date.
If you want to customize this, register a bean of type clock with the application context:
@@ -372,7 +377,8 @@ When routing key is set, requires SNS to be configured as a FIFO topic with cont
|Spring Messaging
|`spring-modulith-events-messaging`
|Uses Spring's core `Message` and `MessageChannel` support.
Resolves the target `MessageChannel` by its bean name given the `target` in the `Externalized` annotation. Forwards routing information as a header - called `modulithRouting` - to be processed in whatever way by downstream components, typically in a Spring Integration `IntegrationFlow`.
Resolves the target `MessageChannel` by its bean name given the `target` in the `Externalized` annotation.
Forwards routing information as a header - called `springModulith_routingTarget` - to be processed in whatever way by downstream components, typically in a Spring Integration `IntegrationFlow`.
|===
@@ -453,7 +459,6 @@ Kotlin::
[[externalization.api]]
=== Programmatic Event Externalization Configuration
The `spring-modulith-events-api` artifact contains `EventExternalizationConfiguration` that allows developers to customize all of the above mentioned steps.
.Programmatically configuring event externalization