Hello,
Actually I wanted to choose the title “Java question: How does the configuration with EventProcessingConfigurer#registerTokenStore work?” but when clicking on “+ Create Topic” the forum software just spawned a popup that reads “Title seems unclear, one or two words is very long?”
I’m sorry for asking a question that is rather on Java but I didn’t receive an answer on stackoverflow. Yet it is of course Axon related because it’s about understanding an idiom that is used in order to configure it. I come from Ruby and I am still quite new to Java and I know from Ruby that some idioms are not obvious on the first glance and probably hard to understand for people who are new to Ruby.
So could you please explain to me how following code works ?
public class AxonConfig {
// ...
public void registerTokenStore(EventProcessingConfigurer processingConfigurer) {
TokenStore tokenStore = JpaTokenStore.builder()
// …
.build();
processingConfigurer.registerTokenStore(config -> tokenStore);
}
}
I have found out about the idiom of functional interfaces with a single method and lambda expressions. Like in the case of EventProcessingConfigurer.PooledStreamingProcessorConfiguration
But this one is different.
registerTokenStore()
is an interface method. Check. The argument is a lambda-expression. Check. But it has a proper argument list, where the return type of the single parameter is a Function placeholder Object (what do you call it in Java?) and the parameter-name is tokenStore, so the method registerTokenStore() is a functional.
I don’t understand what is the config
object that is the single input-parameter of the lambda expression,i.e. what object is passed for this argument and how? Then how is this configuration object which is obviously passed as argument connected to the tokenStore object that it (the lambda expression) returns, and why don’t you pass the tokenStore object directly to the EventProcessingConfigurer
?
And where does finally happen something with the lambda-expression object that you pass as argument?
Thanks !
Yours sincerely,
uberSpotz