Originally posted by Catalin Merfu: NotificationBroadcasterSupport.sendNotification( notif ) works only when called from inside the MBean method invocation (JMX thread) and does nothing when called from an user thread.
I want to spawn a thread inside an MBean method call, perform a lengthy op and send a notif when it's done.
You might want to take a look at it again, because it should work. I do this all the time. In fact, I have mbeans who methods may never ever get called, but they report their status every few minutes. A thread is created upon instantiation, which sends the repeated notifications.
Never used the JMX functionality of log4j, so take answer with a grain of salt.
There is no black magic here. First, I would make sure that the mbean is actually registered. Especially, if you are using mlet to load it, as it is notoriously bad at reporting errors. Second, I would make sure that the listeners were actually added.
The listener should be automatically added when JConsole connects to the mbean server?
Would you be able to post a bean that doesn't export methods but is just used for posting notification?
Don't think I can actually give out customer source code, but here is a snippet from one of them. This mbean does publish an interface, as you need setters and getters for attributes. But this mbean also have a separate thread that periodically sends out attribute change notifications, for an attribute that changes frequently. The method that sends the notification is...
I still don't know why you are so focused on the API itself. If you are losing notifications, I would still look at the mbean server registrations, whether the listeners are added, and whether you are listening for the correct notification.