Skip to content

Instantly share code, notes, and snippets.

@thomasmartin-whoz
Last active November 24, 2021 08:09
Show Gist options
  • Save thomasmartin-whoz/aaef8d91bdeeae8e9873e80d95da44f9 to your computer and use it in GitHub Desktop.
Save thomasmartin-whoz/aaef8d91bdeeae8e9873e80d95da44f9 to your computer and use it in GitHub Desktop.
@Slf4j
@EnableWhozEvent([ProfilePublisher, SkillPublisher])
class WhozPublisherEventConfig {
/**
* Application context from micronaut.
* Event listener must be registered on it as singletons,
* because the bean resolver of the micronaut application listener only evaluates singletons.
*/
@Inject
MicronautApplicationContext applicationContext
@Bean
@Inject
ProfileEventListener profileEventListener(@Qualifier(PROFILE) MessageChannel eventChannel) {
log.info("Enabling whoz events and registering a spring listener to output to $PROFILE")
ProfileEventListener profileEventListener = new ProfileEventListener(eventChannel)
applicationContext.beanFactory.registerSingleton("profileEventListener", profileEventListener)
return profileEventListener
}
@Bean
@Inject
SkillEventListener skillEventListener(@Qualifier(SKILL) MessageChannel eventChannel) {
log.info("Enabling whoz events and registering a spring listener to output to $SKILL")
SkillEventListener skillEventListener = new SkillEventListener(eventChannel)
applicationContext.beanFactory.registerSingleton("skillEventListener", skillEventListener)
return skillEventListener
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment