GH-80 - Renamed ApplicationModuleIntegrationListener to ApplicationModuleListener.
This commit is contained in:
@@ -62,15 +62,12 @@ A different way of approaching this is by moving the event consumption to asynch
|
||||
.An async, transactional event listener
|
||||
[source, java]
|
||||
----
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class InventoryManagement {
|
||||
@Component
|
||||
class InventoryManagement {
|
||||
|
||||
@Async
|
||||
@TransactionalEventListener
|
||||
void on(OrderCompleted event) {
|
||||
|
||||
}
|
||||
void on(OrderCompleted event) { /* … */ }
|
||||
}
|
||||
----
|
||||
|
||||
@@ -79,39 +76,33 @@ While this avoids the expansion of the original business transaction, it also cr
|
||||
Even worse, that doesn't even fully work, as the system might fail before the method is even invoked.
|
||||
|
||||
[[events.amil]]
|
||||
== Application Module Integration Listener
|
||||
== Application Module Listener
|
||||
|
||||
To run a transactional event listener in a transaction itself, it would need to be annotated with `@Transactional` itself.
|
||||
To run a transactional event listener in a transaction itself, it would need to be annotated with `@Transactional` in turn.
|
||||
|
||||
.An async, transactional event listener running in a transaction itself
|
||||
[source, java]
|
||||
----
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class InventoryManagement {
|
||||
@Component
|
||||
class InventoryManagement {
|
||||
|
||||
@Async
|
||||
@Transactional
|
||||
@TransactionalEventListener
|
||||
void on(OrderCompleted event) {
|
||||
|
||||
}
|
||||
void on(OrderCompleted event) { /* … */ }
|
||||
}
|
||||
----
|
||||
|
||||
To ease the declaration of what is supposed to describe the default way of integrating modules via events, Spring Modulith provides `@ApplicationModuleIntegrationListener` to shortcut the declaration
|
||||
To ease the declaration of what is supposed to describe the default way of integrating modules via events, Spring Modulith provides `@ApplicationModuleListener` to shortcut the declaration
|
||||
|
||||
.An application module integration listener
|
||||
.An application module listener
|
||||
[source, java]
|
||||
----
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class InventoryManagement {
|
||||
@Component
|
||||
class InventoryManagement {
|
||||
|
||||
@ApplicationModuleIntegrationListener
|
||||
void on(OrderCompleted event) {
|
||||
|
||||
}
|
||||
@ApplicationModuleListener
|
||||
void on(OrderCompleted event) { /* … */ }
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user