相关文章推荐
开心的山羊  ·  在 SSM ...·  1 年前    · 
粗眉毛的薯片  ·  WPF ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Axon @EndSaga SagaEventHandler is not triggered at all, and @StartSaga SagaEventHandler is retried multiple times

Ask Question

I am trying to create a saga, and start this saga by triggering an event. However, after the event is triggered, I just get an endless loop for "claim on token". and it retries to execute this code all the time. and it just runs it after a few seconds.

@StartSaga
    @SagaEventHandler(associationProperty = "eventId")
    fun on(event: CreateTargetReferenceEvent) {
        println(event.eventId)

My issue here is that I try to trigger @EndSaga event, but it never happened. I am sure the eventId is the same in the @StartSaga and @EndSaga, and both of the events are triggered in the right way since the corresponding event handlers are triggered elsewhere.

I'm not sure what I have missed here to make the @EndSaga triggered. Please help.

This the @Saga component

@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)

And there are the outputs:

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 Add @Transient to your autowired components inside Saga. Seems like you are getting exception while serializing but the stacktrace is hidden. Also @Component is redundant on Saga as @Saga meta annotation covers it. – Vaelyr Nov 2, 2022 at 5:51 0 Yes, adding @Transient above commandGateway in Saga makes it work like magic. Thanks Vaelyr – user4816915 Feb 4 at 2:25

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.