如何使用Axon API为处理组启用并行处理? [英] How to enable Parallel Processing for a processing group using the Axon API?
问题描述
我试图在我的一个处理组(准确地说是一个传奇)上启用并行处理,我遵循了轴突参考,我最后得到了以下
I'm trying to enable parallel processing on one of my processing group (a Saga to be exact), I followed the the Axon Reference and I ended up with the following
@Autowired
public void configureProcessor(Configurer configurer) {
configurer.eventProcessing().registerTrackingEventProcessor("NameOfMySagaProcessor",
org.axonframework.config.Configuration::eventStore,
c -> c.getComponent(
TrackingEventProcessorConfiguration.class,
() -> TrackingEventProcessorConfiguration.forParallelProcessing(1).andInitialSegmentsCount(2).andInitialTrackingToken(StreamableMessageSource::createHeadToken)
)
);
}
我在entry_token表中删除了该传奇的条目,因此它重新填充了所有内容,但自从初始跟踪以来令牌是头部令牌,然后我不希望英雄传奇重播所有事件以达到头部。
I deleted the entry for this saga in my entry_token table so it repopulates everything but since the initial tracking token is a head Token then I'm not expecting the saga to replay all the events to reach head.
PS:这是为什么我不使用spring boot配置的主要原因。因为使用以下内容不允许您选择初始跟踪令牌
PS: This is the main reason why I didn't use the spring boot configuration since using the following doesn't allow you to select the initial tracking token
axon.eventhandling.processors.name.mode = tracking
axon.eventhandling.processors.name.mode=tracking
axon.eventhandling.processors.name.threadCount = 2
axon.eventhandling.processors.name.threadCount=2
axon.eventhandling.processors.name.initialSegmentCount = 4
axon.eventhandling.processors.name.initialSegmentCount=4
spring boot配置可以正常工作,但是又没有初始跟踪令牌,而api配置却无法工作,因为没有任何变化(我的事件没有分成4个部分...)
The spring boot configuration worked but again without an initial tracking token whereas the api configuration didn't work as in nothing changed (my events weren't split into 4 segments...)
我正在使用以下版本的轴突
I am using the following version of axon
compile (group: 'org.axonframework', name: 'axon-spring-boot-starter', version: '4.0.3'){
exclude group:'org.axonframework', module: 'axon-server-connector'
}
推荐答案
最终通过调用以下命令来解决它
Ended up fixing it by calling the following instead
@Autowired
public void configureProcessor(Configurer configurer) {
configurer.eventProcessing().registerTrackingEventProcessor("NameOfMySagaProcessor",
org.axonframework.config.Configuration::eventStore, configuration -> TrackingEventProcessorConfiguration.forParallelProcessing(2).andInitialTrackingToken(StreamableMessageSource::createHeadToken)
);
}
这篇关于如何使用Axon API为处理组启用并行处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!