Axon event handler is skipping events - Stack Overflow

I have latest Spring Boot app, latest Axon Framework, single instance, Postgres as event store, AxonSer

I have latest Spring Boot app, latest Axon Framework, single instance, Postgres as event store, AxonServer community as command and query bus.

Lately mentioned event handler below is rarely skipping this event and not persisting new state to database.

Token entry for this processors shows global index at last event and no gaps.

Same event InvestorBalanceAccountDebitedEvent is handled in few other processing groups and there it persist correctly without any issues, however investorAccountViews now has skipped this event at least 4 times which causes end user to see their old account balance. Fortunately even if the projection is wrong they are not able to operate with that invalid state as it is protected by aggregate.

There are no exceptions thrown as the entity exists always. Any ideas?

Projector with this specific handler:

@Component
@Transactional
@DisallowReplay
@ProcessingGroup(investorAccountViews)
class InvestorAccountProjector(
  val investorAccounts: InvestorAccounts,
  val businessAccounts: BusinessAccounts,
  private val updateEmitter: QueryUpdateEmitter
) {

  @EventHandler
  fun on(event: InvestorBalanceAccountDebitedEvent) {
    val investorAccount = findInvestorAccount(event.investorAccountId)

    investorAccount.accountBalanceAmount = event.newAccountBalanceAmount
  }

  fun findInvestorAccount(investorAccountId: InvestorAccountId): InvestorAccountView {
    return investorAccounts.findOne(valueEquals(InvestorAccountView_.investorAccountUid, investorAccountId.id))
      .orElseThrow { RuntimeException("Investor account $investorAccountId not found") }
  }
}

Axon Configuration (no specific configuration for handlers, all are pooled with 6 segments)

  @Bean
  fun configure(): ConfigurerModule {
    return ConfigurerModule { configurer ->
      val psepConfig = EventProcessingConfigurer.PooledStreamingProcessorConfiguration { _, builder -> builder.initialSegmentCount(6) }
      configurer.eventProcessing()
        .usingPooledStreamingEventProcessors(psepConfig)
    }
  }

I have latest Spring Boot app, latest Axon Framework, single instance, Postgres as event store, AxonServer community as command and query bus.

Lately mentioned event handler below is rarely skipping this event and not persisting new state to database.

Token entry for this processors shows global index at last event and no gaps.

Same event InvestorBalanceAccountDebitedEvent is handled in few other processing groups and there it persist correctly without any issues, however investorAccountViews now has skipped this event at least 4 times which causes end user to see their old account balance. Fortunately even if the projection is wrong they are not able to operate with that invalid state as it is protected by aggregate.

There are no exceptions thrown as the entity exists always. Any ideas?

Projector with this specific handler:

@Component
@Transactional
@DisallowReplay
@ProcessingGroup(investorAccountViews)
class InvestorAccountProjector(
  val investorAccounts: InvestorAccounts,
  val businessAccounts: BusinessAccounts,
  private val updateEmitter: QueryUpdateEmitter
) {

  @EventHandler
  fun on(event: InvestorBalanceAccountDebitedEvent) {
    val investorAccount = findInvestorAccount(event.investorAccountId)

    investorAccount.accountBalanceAmount = event.newAccountBalanceAmount
  }

  fun findInvestorAccount(investorAccountId: InvestorAccountId): InvestorAccountView {
    return investorAccounts.findOne(valueEquals(InvestorAccountView_.investorAccountUid, investorAccountId.id))
      .orElseThrow { RuntimeException("Investor account $investorAccountId not found") }
  }
}

Axon Configuration (no specific configuration for handlers, all are pooled with 6 segments)

  @Bean
  fun configure(): ConfigurerModule {
    return ConfigurerModule { configurer ->
      val psepConfig = EventProcessingConfigurer.PooledStreamingProcessorConfiguration { _, builder -> builder.initialSegmentCount(6) }
      configurer.eventProcessing()
        .usingPooledStreamingEventProcessors(psepConfig)
    }
  }
Share Improve this question asked Mar 22 at 8:58 VaelyrVaelyr 3,1862 gold badges23 silver badges37 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

That's a bummer, @Vaelyr!

Although I get the assumption that the events are skipped, I do need to stress that if the projection doesn't show it, that does not necessarily mean the event was never passed through the (in your scenario) PooledStreamingEventProcessor. Differently put, the storage layer might've done something funky why the desired change got lost.

I know fully well that the above comment doesn't help you at all, so let me pose two ideas.

Firstly, I am wondering what happens when you replay this InvestorAccountProjector. Is the exact same event skipped again? If so, we have something curious going on. However, I would expect that the replay will either (1) solve all missed events or (2) turns up with other events being skipped.

Secondly, I think it's worthwhile to do some investigation. I've been in the habit of adding a, albeit verbose, LoggingInterceptor to Event Processor that have misbehaving Event Handling Components. The benefit of the interceptor is that it'll show any occurrence of handling the InvestorBalanceAccountDebitedEvent. Then, if the log statements also miss the events, we're dealing with an Axon Framework or storage-solution issue. If the log statements do show up for events that did not lead to projection changes, then we'd need to investigate the storage layer.

Sadly, still not a direct solution for you here, @Vaelyr, sorry for that. However, I think we should dig a little deeper to figure things out. If you have more information, be sure to update your question. I'll update my answer as a response to that.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744321207a4568424.html

相关推荐

  • Axon event handler is skipping events - Stack Overflow

    I have latest Spring Boot app, latest Axon Framework, single instance, Postgres as event store, AxonSer

    7天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信