首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Axon @EndSaga SagaEventHandler根本没有触发,@StartSaga SagaEventHandler被多次重试

Axon @EndSaga SagaEventHandler根本没有触发,@StartSaga SagaEventHandler被多次重试
EN

Stack Overflow用户
提问于 2022-11-01 11:59:05
回答 2查看 34关注 0票数 0

我试图创造一个传奇,并通过触发事件开始这一传奇。然而,在事件被触发后,我只会得到一个无休止的循环,用于“令牌上的声明”。它总是尝试执行这段代码。几秒钟后它就能运行了。

代码语言:javascript
运行
复制
@StartSaga
    @SagaEventHandler(associationProperty = "eventId")
    fun on(event: CreateTargetReferenceEvent) {
        println(event.eventId)
    }

我在这里的问题是,我试图触发@EndSaga事件,但从未发生过。我确信eventId在@StartSaga和@EndSaga中是相同的,这两个事件都是以正确的方式触发的,因为相应的事件处理程序是在其他地方触发的。

我不知道我错过了什么让@EndSaga触发。请帮帮忙。

这是@Saga组件

代码语言:javascript
运行
复制
@Component
@Saga
internal class TestSaga {
    var testString: String = ""

    @Autowired
    private lateinit var commandGateway: CommandGateway
    
    @StartSaga
    @SagaEventHandler(associationProperty = "eventId")
    fun on(event: CreateTargetReferenceEvent) {
        println(event.eventId)
    }

    @EndSaga
    @SagaEventHandler(associationProperty = "eventId")
    fun on(event: UpdateTargetReferenceEvent) {
        println(event.eventId)
    }
}

这方面的产出如下:

代码语言:javascript
运行
复制
    2022-11-01 21:49:10.529  WARN 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor             : Releasing claim on token and preparing for retry in 4s
    Hibernate: update token_entry set owner=null where owner=? and processor_name=? and segment=?
    2022-11-01 21:49:10.530  INFO 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor             : Released claim
    Hibernate: update token_entry set timestamp=? where processor_name=? and segment=? and owner=?
    Hibernate: update token_entry set timestamp=? where processor_name=? and segment=? and owner=?
    Hibernate: update token_entry set timestamp=? where processor_name=? and segment=? and owner=?
    Hibernate: select tokenentry0_.processor_name as processo1_7_0_, tokenentry0_.segment as segment2_7_0_, tokenentry0_.owner as owner3_7_0_, tokenentry0_.timestamp as timestam4_7_0_, tokenentry0_.token as token5_7_0_, tokenentry0_.token_type as token_ty6_7_0_ from token_entry tokenentry0_ where tokenentry0_.processor_name=? and tokenentry0_.segment=? for update
    Hibernate: update token_entry set owner=?, timestamp=?, token=?, token_type=? where processor_name=? and segment=?
    2022-11-01 21:49:14.536  INFO 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor             : Fetched token: null for segment: Segment[0/0]
    Hibernate: update token_entry set token=?, token_type=?, timestamp=? where owner=? and processor_name=? and segment=?
    Hibernate: select associatio0_.saga_id as col_0_0_ from association_value_entry associatio0_ where associatio0_.association_key=? and associatio0_.association_value=? and associatio0_.saga_type=?
    baccd32c-1547-4621-a04c-3a5cb285a9af
    2022-11-01 21:49:14.551  WARN 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor             : Releasing claim on token and preparing for retry in 8s
    Hibernate: update token_entry set owner=null where owner=? and processor_name=? and segment=?
    2022-11-01 21:49:14.553  INFO 11916 --- [agaProcessor]-0] o.a.e.TrackingEventProcessor             : Released claim
EN

Stack Overflow用户

发布于 2022-11-02 06:40:13

正如Vaelyr所说,不要使用@Component。它不是一个组件,因为它有一个不同的生命周期。通常使用Saga,您可以在不同的集合上进行编排。因此,UpdateTargetReferenceEvent将由佐贺发送的命令触发。

票数 1
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74275584

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档