Get the entire stack trace fpr remote command handlers

29 views
Skip to first unread message

Shreya Saha

unread,
Jul 31, 2020, 5:58:10 AM7/31/20
to Axon Framework Users
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? 

Steven van Beelen

unread,
Sep 16, 2020, 6:33:32 AM9/16/20
to Axon Framework Users
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!

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/axonframework/40d31a9d-3ab1-4ada-b82f-3d49caa98d78o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages