Search code examples
javaspring-bootjmxspring-boot-actuatorjconsole

Changing method invocation pop-up response in jConsole


I am exposing some operations in a class in my Spring Boot application through JMX. However, in jConsole, when I invoke the method, "Method invoked successfully" pops up. I know that's because the method returns nothing. But I want to show useful information when method invoked.

I am using @ManagedOperation which is provided by Spring, but it has no such property. I couldn't find anything on the documentation, either. I can notify the executor by sending a notification, but I wonder if there's any way of directly alerting information.

This is how it normally alerts.

enter image description here

Let me give an example. I have multiple containers that are running and I have provided an operation to stop and start them. When, for example, start is invoked, I want it to alert that "Container X has started" or "Container X is already running". I can do this, by returning these responses as string from the method, but I don't think this should be the way to go. I wonder if a way to do this exists through the API itself.

Hope, I'm clear.


Solution

  • That's not possible and you cannot change the jConsole behavior.

    To your example:

    If you have multiple outcomes of the invoked method it makes perfectly sense to return this as the message.

    But maybe you should consider to expose these as HTTP endpoints where you can return an appropriate HTTP status code instead of a string.