Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Issue: MessageHandlerInterceptor should return a value when a Message Handler has a return value #209

Open
edreyer opened this issue Jul 8, 2021 · 1 comment

Comments

@edreyer
Copy link

edreyer commented Jul 8, 2021

This applies to projects using the Reactor extension only (I think).

If a @CommandHandler method returns a value, any @MessageHandlerInterceptor interceptor methods must also return a value, or that value is lost and null is returned to the message sender.

e.g.

@MessageHandlerInterceptor(messageType = CommandMessage::class)
fun handleTheThing(
  cmdMsg: CommandMessage<*>,
  chain: InterceptorChain
): Any {
  return chain.proceed() // must return or value is lost
}

I discovered this via some trial and error. It might be helpful if the docs also reflected this.

@smcvb
Copy link
Collaborator

smcvb commented Jul 12, 2021

Thanks for this suggestion @edreyer. Returning values from command handlers is also an option when you're not using Project Reactor.

The addition Axon's Reactor Extension provides is the ReactorResultHandlerInterceptor, which I am guessing you're confusion this requirement with.
No worries though there.

At any note, I agree it would be beneficial to provide some "gotchas" when it comes to constructing interceptors. That set would thus also contain some specifics about return values from message handling functions and that the InterceptorChain's result is paramount to actually get the result back. I'd wager the Message Intercepting page would be ideal for that actually.

@smcvb smcvb changed the title Documentation Issue: Reactor Extension: method handler interceptors must return a value Documentation Issue: MessageHandlerInterceptor should return a value when a Message Handler has a return value Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants