diff --git a/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java b/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java index 64a320f3..ed03124e 100644 --- a/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java +++ b/src/main/java/org/openwms/wms/movements/impl/MovementEventListener.java @@ -15,6 +15,7 @@ */ package org.openwms.wms.movements.impl; +import org.ameba.annotation.Measured; import org.ameba.exception.NotFoundException; import org.ameba.i18n.Translator; import org.openwms.common.location.api.LocationApi; @@ -23,6 +24,8 @@ import org.openwms.common.transport.api.messages.TransportUnitMO; import org.openwms.wms.movements.spi.common.AsyncTransportUnitApi; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.event.TransactionalEventListener; import static org.openwms.wms.movements.MovementsMessages.LOCATION_NOT_FOUND_BY_ERP_CODE; @@ -45,7 +48,9 @@ class MovementEventListener { this.asyncTransportUnitApi = asyncTransportUnitApi; } + @Measured @TransactionalEventListener + @Transactional(propagation = Propagation.REQUIRES_NEW) public void onEvent(MovementTargetChangedEvent event) { var locationByErpCode = locationApi.findByErpCode(event.getSource().getTargetLocation()); if (locationByErpCode.isPresent()) { diff --git a/src/main/java/org/openwms/wms/movements/impl/MovementEventPropagator.java b/src/main/java/org/openwms/wms/movements/impl/MovementEventPropagator.java index e93469a3..e0fc3d0a 100644 --- a/src/main/java/org/openwms/wms/movements/impl/MovementEventPropagator.java +++ b/src/main/java/org/openwms/wms/movements/impl/MovementEventPropagator.java @@ -15,6 +15,7 @@ */ package org.openwms.wms.movements.impl; +import org.ameba.annotation.Measured; import org.openwms.core.SpringProfiles; import org.openwms.wms.movements.commands.MovementMO; import org.slf4j.Logger; @@ -23,7 +24,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; -import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.event.TransactionalEventListener; import static org.openwms.wms.movements.events.api.MovementEvent.Type.CANCELLED; @@ -52,7 +54,9 @@ class MovementEventPropagator { this.amqpTemplate = amqpTemplate; } - @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + @Measured + @TransactionalEventListener + @Transactional(propagation = Propagation.REQUIRES_NEW) public void onEvent(MovementEvent event) { var movement = event.getSource(); var vo = MovementMO.newBuilder() diff --git a/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java b/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java index 127e7ef6..b4fcb242 100644 --- a/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java +++ b/src/main/java/org/openwms/wms/movements/impl/PutawayAdapter.java @@ -15,6 +15,7 @@ */ package org.openwms.wms.movements.impl; +import org.ameba.annotation.Measured; import org.ameba.annotation.TxService; import org.openwms.wms.movements.Message; import org.openwms.wms.movements.MovementProperties; @@ -26,7 +27,6 @@ import org.springframework.context.ApplicationEventPublisher; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.event.TransactionPhase; import org.springframework.transaction.event.TransactionalEventListener; /** @@ -53,7 +53,8 @@ class PutawayAdapter { } @ConditionalOnExpression("${owms.movement.putaway-resolution-enabled}") - @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + @Measured + @TransactionalEventListener @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {Exception.class}) public void onEvent(MovementEvent event) { var movement = event.getSource(); diff --git a/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java b/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java index c871fe8f..9f09b519 100644 --- a/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java +++ b/src/main/java/org/openwms/wms/movements/impl/TransactionWriter.java @@ -15,6 +15,7 @@ */ package org.openwms.wms.movements.impl; +import org.ameba.annotation.Measured; import org.ameba.exception.NotFoundException; import org.ameba.http.ctx.CallContext; import org.ameba.http.ctx.CallContextHolder; @@ -33,6 +34,8 @@ import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.event.TransactionalEventListener; import static org.openwms.transactions.api.commands.TransactionCommand.Type.CREATE; @@ -66,7 +69,9 @@ class TransactionWriter { this.asyncTransactionApi = asyncTransactionApi; } + @Measured @TransactionalEventListener + @Transactional(propagation = Propagation.REQUIRES_NEW) public void onEvent(MovementEvent event) { switch (event.getType()) { case MOVED: @@ -108,7 +113,9 @@ public void onEvent(MovementEvent event) { } } + @Measured @TransactionalEventListener + @Transactional(propagation = Propagation.REQUIRES_NEW) public void onEvent(MovementTargetChangedEvent event) { var locationByErpCode = locationApi.findByErpCode(event.getSource().getTargetLocation()); if (locationByErpCode.isPresent()) {