Get the entire stack trace fpr remote command handlers

We have two separate micro services. One of them publishes a command which is being handled by a command handler present in the other micro service. In case the command handler faces any errors (NullPointerException, SQLException etc), the stack trace shows the following :

An error was thrown by the remote message handling component: java.lang.NullPointerException: null

It gives the stack trace for the micro service which publishes the command using the command Gateway. I cannot share the code or the entire stack here as it is in my companys system. Is there a way in which we can get the entire stack trace for the command handler?

Hi Shreya,

To achieve this, you will have to throw the CommandExecutionException yourself, and here is why.
Between distinct services, Axon cannot be certain that the thrown exception is on the classpath of the original sender of the command/message.
As such, we refrain from even trying that, and we throw a CommandExecutionException.

What you can do on your end to provide more details to this CommandExecutionException, is by throwing it yourself and providing a “details” Object to the constructor.
This “details” object can be anything you desire. The stack trace, a String, or a status code.

Easiest way to catch any command handling exception and throw the CommandExecutionException, is by introducing a MessageHandlerInterceptor.
This interceptor then catches the exception thrown (by putting a try-catch block around the InterceptorChain#proceed operation) by your message handler, rethrowing it as a CommandExecutionException with the desired details.

Trust this helps you further Shreya!

Cheers,
Steven

PS. It is important to note that this mailing list will be discontinued as specified in this thread.
Instead of this mailing list we have moved to use a forum style of communication, at https://discuss.axoniq.io/.

Hope to see you there!