I’m using Axon Server 2025.4.1 as an event store with Axon Framework 4.7.0.
I’ve noticed that an @EventHandler
is only invoked when I explicitly annotate its class with @ProcessingGroup
; without that annotation, the handler is never triggered.
In the aggregate I can see the command-handling log and the event-sourcing logs, but nothing is logged inside the @EventHandler
.
Could anyone explain why the handler is ignored when no @ProcessingGroup
is provided?
this is my code
CreateReconciliationDraftCommand command =
new CreateReconciliationDraftCommand(
newReconciliationNo,
newReconciliationName,
originalReconciliation.getStartDate(),
originalReconciliation.getEndDate(),
originalReconciliation.getReconciliationDate(),
transportType,
originalReconciliation.getConsignorCorpCode(),
originalReconciliation.getConsignorCorpName(),
originalReconciliation.getCarrierCorpCode(),
originalReconciliation.getCarrierCorpName(),
reconciliationItems,
originalReconciliation.getCumulativeAmount(),
originalReconciliationNo);
// @formatter:on
commandGateway.send(command);
this is my aggregate
@Slf4j
@Getter
@Aggregate
public class ReconciliationAggregate {
// 对账单编号
@AggregateIdentifier
private String reconciliationNo;
protected ReconciliationAggregate() {
}
// =============================================
// 命令处理器 - 创建对账单草稿
// =============================================
@CommandHandler
public ReconciliationAggregate(CreateReconciliationDraftCommand command) {
// 基础验证
Assert.notEmpty(command.getItems(), () -> "运单列表不能为空");
log.info("create draft command handler->{}",command);
// 发布事件
// @formatter:off
apply(
new ReconciliationDraftCreatedEvent(
command.getReconciliationNo(),
command.getName(),
command.getStartDate(),
command.getEndDate(),
command.getReconciliationDate(),
command.getTransportType(),
command.getConsignorCorpCode(),
command.getConsignorCorpName(),
command.getCarrierCorpCode(),
command.getCarrierCorpName(),
command.getItems(),
calculateTotalAmount(command.getItems()),
calculateTotalWeight(command.getItems()),
command.getCumulativeAmount(),
command.getItems().size(),
ReconciliationStatus.DRAFT,
command.getHistoryReconciliationNo()));
// @formatter:on
}
@EventSourcingHandler
public void on(ReconciliationDraftCreatedEvent event) {
log.info("ReconciliationDraftCreatedEvent: {}", event);
this.reconciliationNo = event.getReconciliationNo();
}
this is my projection
package com.smartchain.tms.reconciliation.query.projections;
@Slf4j
@Component
//@ProcessingGroup("reconciliation")
@RequiredArgsConstructor
public class ReconciliationProjection {
private final ReconciliationItemService reconciliationItemService;
private final ReconciliationService reconciliationService;
@EventHandler
@Transactional
public void on(ReconciliationDraftCreatedEvent event) {
log.info("处理对账单草稿创建事件: {}", event.getReconciliationNo());
}
but i get this log