I have a white label/multi-tennant server providing the same services, but branded for multiple customers. I want to use JMX to monitor the status of each customer (nbr of calls, nbr of errors, etc).
I know how to use Spring JMX annotations to wire up my POJOs (per the code below). What I really want is one MBean per customer, but because the customers are dynamically loaded up at server startup time I don’t know how to wire this up using annotations.
Is this possible? If not, is it possible to instantiate my MBeans at startup time ?
@Component
@ManagedResource(objectName = "TravelAPI:name=Customer")
public class CustomerStatus extends GeneralCustomerStatus {
@ManagedAttribute
String customerId;
.
.
.
}
What we do is to have the entity that is actually instantiating your dynamic objects, register them with JMX via the
MBeanExporter. We inject theMBeanExporterinstance into the factory entity and then callMBeanExporter.registerManagedResource(...).For example we do something like:
We also use a
NamingPolicyso that the dynamic objects can provide their own names to make them unique. See more details about that here:As an aside, my SimpleJMX package has some code to help with dynamic objects.