I have Stateless Session bean, that I would like to collect some runtime stats on. For example, how often it catches a RollBack exception, how many times it retries, etc.
My thinking is that these run time status represent a form of instrumentation. And that as soon as I think instrumentation I should be thinking JMX. Does this make sense?
If so, it is simple to make my own MBean and have the EJB talk to it. I can even put my initialization values, such as number of retires, right into the MBean. But isn't there an even easier way? Since all JBoss EJBs are implemented as MBeans anyway isn't there just some way to collect this stuff in that MBean?
So, what I've found is that while JBoss collects a lot of runtime stats inforamtion on EJBs I needed additional inforamtion stuff in this specific case. So I wrote a simple MBean and called it from the EJB. Works fine. Seems like a reasonable approach. And more importantly, it helped me locate a bug, which only occurred when I had hundreds of threads.