I got this working with some help from someone in camel irc (thanks davidk).
It bypasses the camel jmx completely and just relies on Spring (I
think cibsen recommended this approach to me yesterday but I was being
stubborn).

In case it helps anyone, you need to create (or configure) the mbean exporter.
I use spring java configs so its just adding:

    @NotNull
    @Bean
    public MBeanExporter mbeanExporter() {
        return new AnnotationMBeanExporter();
    }

to one of your Spring scanned configurations.
You can then remove the interfaces but need to make sure that you have
a well formed objectName.
In my case, I just changed it to:

@ManagedResource("bean:name=MyMBean")

On Wed, Jan 12, 2011 at 3:16 PM, Tim <che...@gmail.com> wrote:
> I'm using Camel 2.5 and trying to register my own MBean.
> After struggling a bit to figure out how (the docs seem outdated on
> this and the book wasn't very helpful about it).
> I came up with an MBean class that looks like:
>
> @ManagedResource(objectName = "MyMBean")
> public class MyMBean implements Service, ManagementAware<MyMBean> {
> .....
>   �...@notnull
>   �...@override
>    public Object getManagedObject(@NotNull MyMBean aMBean) {
>        LOGGER.warn("Mananaging {}", aMBean);
>
>        return this;
>    }
> }
>
>
> Even though this MBean is used in a created by Spring and used in a
> camel route it does not show up in the jmx section correctly until I
> also add:
>
>        try {
>            final ManagementStrategy myManagementStrategy =
> getContext().getManagementStrategy();
>            final ManagementNamingStrategy myManagementNamingStrategy
> = myManagementStrategy.getManagementNamingStrategy();
>
>            myManagementStrategy.manageNamedObject(theMBean,
> myManagementNamingStrategy.getObjectNameForService(getContext(),
> theMBean));
>        } catch (Exception myException) {
>            throw new IllegalStateException(myException);
>        }
>
> Is there a way to avoid this? I know Camel 2.6 says that MBeans only
> need to be annotated to be registered but this is in Camel 2.5
>

Reply via email to