Confusion about Event routing

After reading the current docs a small confusion arised after attempting a prototype application. A small example will hopefully illustrate this.
Imagine a domain with Product and Order aggregates. An order contains a set of OrderLine entities that each reference a Product.

The following code can be written:

`
public class Order {

@AggregateIdentifier
private OrderId orderId;

@AggregateMember
private Set lines;

@CommandHandler
public Order(CreateOrderCmd cmd) {
apply(new OrderCreated(
cmd.getOrderId(),
cmd.getOrderLines());
}

@EventSourcingHandler
private void on(OrderCreated event) {
this.orderId = event.getOrderId();
this.lines = event.getOrderLines();
}

// …

}

public class OrderLine {

@EntityId
private OrderLineId orderLineId;
private ProductId productId;

// constructor and methods omitted for brevity

}
`

Every Product aggregate has a ProductStatus. When an Order with its OrderLines is created, every referenced Product should be updated with a new status ProductStatus.ORDER_CREATED.This is exactly where the confusion exists. How can I route this event to the correct Product aggregate?

`
public class Product {

@AggregateIdentifier
private ProductId productId;
private ProductStatus status;

// …

@EventSourcingHandler
private void on(OrderCreated event) {
this.status = ProductStatus.ORDER_CREATED;
}

// …

}
`

Hi,

In Axon, events aren’t routed between aggregates directly. If you want an aggregate to perform an action based on an event, you’d need to have an event handler (or Saga) that translates that event to a command.

Cheers,

Allard