question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default Tracking Token to head in case of Sagas

See original GitHub issue

When a SagaConfigurer will make the Saga instance use a TrackingEventProcessor as the mechanism to receive events, it would be beneficial to make the initialTrackingToken of that Processor start at the head.

The thought behind this is that if a new Saga is introduced into the stack, you’d typically want to start that at the point in time you introduce that logic. Hence, the TrackingToken for the Tracking Processor of such a Saga should start at that point in time.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
smcvbcommented, Nov 4, 2020

I might not have been overly clear with my response @muradm, but “Allowing to configure TrackingEventProcessorConfiguration on per saga/processing group” is actually possible at the moment. Figured that was clear from my response, but I guess I have jumped to many hops then.

Let me restate my solution in a full fledged sample, something I tried to avoid the previous time around:

// Some Saga which we want to start from the head
@Saga
class MySampleSaga { ... }

...

// Our Configuration class to set up our MySampleSaga to start at the head
@Configuration
class AxonConfig {

    @Autowired
    public void configureMySampleSaga(EventProcessingConfigurer eventProcessingConfigurer) {
        TrackingEventProcessorConfiguration tepConfig =
                TrackingEventProcessorConfiguration.forSingleThreadedProcessing()
                                                   .andInitialTrackingToken(StreamableMessageSource::createHeadToken);
        String processorName = "MySampleSagaProcessor";

        eventProcessingConfigurer.registerTrackingEventProcessor(
                processorName, Configuration::eventStore, config -> tepConfig
        );
    }
}

Doing the above will ensure that whenever you start the TrackingEventProcessor (TEP) of your Saga for the first time, the token will be add the head of the stream. So there you are simply configuring the TEP used by your MySampleSaga to start it’s TrackingToken at the head of the stream. Retrieving such a token is the job of the StreamableMessageSource you are using, which typically defaults to the EventStore implementation used in your application.

Trusting this helps you out further @muradm.

0reactions
smcvbcommented, Nov 5, 2020

We’ve actually quite recently introduce a dedicated samples repository just for that purpose. This repo will be further filled up as time progresses, likely searchable through a different portal as well. So, happy to hear you find it valuable, stay tuned for more to come 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Saga Tracking Token always initialized with latest globalIndex
A Streaming Processor dedicated to a Saga will default the initial token to the head of the stream. The default initial token position ......
Read more >
React and Redux Sagas Authentication App Tutorial, Part 3
Just gives a token back signed with it's secret and some contextual data. In this case, the token is both the proof of...
Read more >
Starting a Saga conditionally · Issue #1900 - GitHub
We have configured a separate message source (set as the default) that reads all data back in and emits it to the event...
Read more >
Axon Saga not getting created - Stack Overflow
I suspect the reason for this behaviour is that the token of the Saga Processor is already at the head of the event...
Read more >
Confused about Configuration in Axon 4. - Google Groups
(I.e. setting the initial tracking token). Speaking of which we think the default should be the head token, not the tail. (A clean...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found