MBeans не отображаются в jvisualVM

Приложение Monitor Spring Integration отлично подходит.

Я хотел бы добавить простой MBean для мониторинга приложения. Вот мой код:

package com.example;

import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;

@Component
@ManagedResource(objectName="myapp:application=hello")

public class HelloBean {

    @ManagedOperation
    public String sayHello(String name) {
       return "Hello " + name;
    }
}

Я также добавил следующее в XML-файл spring-context:

<context:mbean-server />
<int-jmx:mbean-export id="integrationMBeanExporter" default-domain="spring.application" />

<bean id="helloBean" class="com.example.HelloBean" />

когда я смотрю в jVisualVM, я не вижу бин. Я вижу MessageChannel в домене spring.application, но не вижу свой MBean. изображение MBeans в spring.integration

Что еще нужно сделать, чтобы аннотированные MBeans отображались в VisualVM?

Спасибо.


person kevin    schedule 09.06.2016    source источник


Ответы (1)


<context:mbean-export/> для вас.

<int-jmx:mbean-export> — это пользовательский MBeanExporter для компонентов Spring Integration. Всем остальным должен управлять стандартный Spring <context:mbean-export/>.

person Artem Bilan    schedule 09.06.2016
comment
Это идеально. Я добавил ‹context:mbean-export/› и теперь вижу свой bean-компонент. Большое спасибо. - person kevin; 10.06.2016
comment
Как реализовать то же самое с Java DSL только в SI 4.x? - person Andriy Kryvtsun; 24.05.2018
comment
Я думаю, вам, что посмотреть это: EnableIntegrationMBeanExport. См. здесь: docs.spring.io/spring-integration/docs/5.0.5.RELEASE/reference/ - person Artem Bilan; 24.05.2018