Hi,
In my project we are using AXON 3.2.2 .After upgrading to latest stable 3.3.2 , existing entity update and event firing is not working and below exception is throwing
As per my understanding a new feature 'scope ' need to added for messaging on latest release .please help me to understand how we can configure scope feature in entity for update along with event firing
java.lang.IllegalStateException: Cannot request current Scope if none is active
at org.axonframework.messaging.Scope.getCurrentScope(Scope.java:41) ~[axon-core-3.3.2.jar:3.3.2]
at org.axonframework.commandhandling.model.AggregateLifecycle.getInstance(AggregateLifecycle.java:130) ~[axon-core-3.3.2.jar:3.3.2]
at org.axonframework.commandhandling.model.AggregateLifecycle.apply(AggregateLifecycle.java:67) ~[axon-core-3.3.2.jar:3.3.2]
at com.acme.ecom.product.model.Product.depreciateStock(Product.java:103) ~[classes/:na]
Entity
---------------
@Entity
@Table(name="ECOM_PRODUCT")
public class Product{
private static final long serialVersionUID = 1L;
@Id
private Integer id;
@Column(name="PRICE")
private Double price;
------------------------------------
public void depreciateStock(int count){
if(this.stock >= count){
this.stock = this.stock - count;
apply(new StockUpdatedEvent(id, stock));
}else{
throw new RuntimeException("Out of stock");
}
}
.........................
......................
Commnd Handler
@CommandHandler
public void handle(NewOrderCommand newOrderCommand) throws Exception{
AnnotatedAggregate<Product> productAggregate = productRepository.load(
newOrderCommand.getProductId().toString()).getWrappedAggregate();
Product product = productAggregate.getAggregateRoot();
product.depreciateStock(newOrderCommand.getNumber());
....................................
...........................