-
15. Re: migrating from ServiceMBeanSupport
alesj Nov 29, 2007 8:30 AM (in response to jhalliday)And an example of dependency?
Dunno how lifecycle works if your mbean is not an instance of Service anymore, or if it's wrapped in some Service impl ...public void installAction(ServiceControllerContext context) throws Throwable { Service service = context.getServiceProxy(); service.start(); context.getServiceContext().state = ServiceContext.RUNNING; ObjectName objectName = context.getObjectName(); ServiceController serviceController = context.getServiceController(); serviceController.sendControllerNotification(ServiceMBean.START_EVENT, objectName); }
-
16. Re: migrating from ServiceMBeanSupport
jhalliday Nov 29, 2007 8:47 AM (in response to jhalliday)> And an example of dependency?
look at jboss-service.xml in AS trunk and take your pick.<mbean code="org.jboss.invocation.local.LocalInvoker" name="jboss:service=invoker,type=local"> <depends>jboss:service=TransactionManager</depends> </mbean>
> Dunno how lifecycle works if your mbean is not an instance of Service anymore,
huh? I thought the whole point of MC was that you could use POJOs. Now it appears I have to implement or subclass something? Arggg. How does that leave me any better off than not changing my code at all. I may as well stick with 'extends ServiceMBeanSupport' -
17. Re: migrating from ServiceMBeanSupport
alesj Nov 29, 2007 6:08 PM (in response to jhalliday)"jhalliday" wrote:
huh? I thought the whole point of MC was that you could use POJOs. Now it appears I have to implement or subclass something? Arggg. How does that leave me any better off than not changing my code at all. I may as well stick with 'extends ServiceMBeanSupport'
Define TM as MC bean, not as mbean, and you're done. ;-)
Why the mbean XML? -
18. Re: migrating from ServiceMBeanSupport
jhalliday Nov 30, 2007 3:16 AM (in response to jhalliday)> Why the mbean XML?
Umm, because I want operations on it exposed via. JMX? Just because we use MC internally in the app server, that does not mean JMX goes away. There are still likely to be 3rd party tools wanting to use JMX to manage the server, so I need some way to wire the service up as an mbean. This seemed like the easiest route. If you can suggest another approach I'll happily change. Assuming of course I don't have to cascade the change to everything that depends on the tx manager and expects it to be an mbean.
Thanks -
19. Re: migrating from ServiceMBeanSupport
alesj Nov 30, 2007 6:04 AM (in response to jhalliday)@JMX? ;-)
-
20. Re: migrating from ServiceMBeanSupport
alesj Nov 30, 2007 7:01 AM (in response to jhalliday)Check ServiceControllerLifecycleCallback in AS5_trunk.
And a lot of cluster beans use this @org.jboss.aop.microcontainer.aspects.jmx.JMX.
Or see EjbDeployer for non-xml usage. -
21. Re: migrating from ServiceMBeanSupport
jhalliday Dec 19, 2007 9:15 AM (in response to jhalliday)The JMX annotation seems a good approach at first, but when I replace the old mbean
<mbean code="com.arjuna.ats.jbossatx.jta.TransactionManagerService" name="jboss:service=TransactionManager"> <attribute name="TransactionTimeout">300</attribute> <attribute name="ObjectStoreDir">${jboss.server.data.dir}/tx-object-store</attribute> </mbean>
with the new annotated bean<bean name="TransactionManager" class="com.arjuna.ats.jbossatx.jta.TransactionManagerService"> <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=TransactionManager", exposedInterface=com.arjuna.ats.jbossatx.jta.TransactionManagerServiceMBean.class, registerDirectly=true)</annotation> <property name="TransactionTimeout">300</property> <property name="ObjectStoreDir">${jboss.server.data.dir}/tx-object-store</property> </bean>
then the dependent mbeans e.g.<mbean code="org.jboss.invocation.unified.server.UnifiedInvoker" name="jboss:service=invoker,type=unified"> <depends>jboss:service=TransactionManager</depends> <depends>jboss.remoting:service=Connector,transport=socket</depends> </mbean>
fail to find the service they depend on:... 14:01:46,883 INFO [JMXKernel] Legacy JMX core initialized 14:01:59,184 INFO [WebService] Using RMI server codebase: http://127.0.0.1:8083/ 14:02:01,913 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS): *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State} jboss:service=invoker,type=jrmp -> jboss:service=TransactionManager{Start:** NOT FOUND **} -> jboss:service=TransactionManager{Create:** NOT FOUND **} ... *** CONTEXTS IN ERROR: Name -> Error jboss:service=TransactionManager -> ** NOT FOUND **
Perhaps the annotation is being processed at a later stage of the lifecycle so it's not yet present when the mbean dependencies go to look for it?
Anyhow, it seems there are issues with interop between the old mbean style and the new bean style. My options at this point seem equally unpalatable: either link the transactions code again some new AS library (lots of work with no apparent advantage over the existing situation of linking against ServiceMBeanSupport) or convert everything that depends on the transaction manager from mbeans to beans also, transitively. I vote for option 3: do nothing. ServiceMBeanSupport works ok, why bother with this new MC stuff? -
22. Re: migrating from ServiceMBeanSupport
alesj Dec 19, 2007 1:13 PM (in response to jhalliday)You are missing the point and some code/xml - see jboss-aspect-library-beans.xml.
I've hacked together a JMXAnnotationTestCase for you in the AS5_trunk/system-jmx.
See the test class, and two matching xmls - JMXAnnotationTestCase.xml and JMXAnnotationTestCase-mc.xml.
It's all there, you just need to look better, and not whine over MC. ;-) -
23. Re: migrating from ServiceMBeanSupport
adrian.brock Dec 21, 2007 11:19 AM (in response to jhalliday)This is a known "bug" (really a configuration issue) currently in JBoss5.
The issue is that the AOP advice for @JMX is not installed until
after conf/jboss-service.xml or bootstrap-beans.xml is processed.
This is because it is done by the aop deployer which runs later.
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=125347
In general the implementation details (rather than the deployment layer)
like the transaction manager should be in "deploy" anyway,
\but there's lots of work to be done before that is possible. e.g.
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=112404
to properly define dependencies and make sure deployers are
properly seperated from runtime infrastructure. -
24. Re: migrating from ServiceMBeanSupport
jhalliday Jan 2, 2008 9:44 AM (in response to jhalliday)> You are missing the point and some code/xml
Yes, thanks Ales, the missing link seems to be the functionality in TestServiceControllerLifecycleCallback. I had assumed that declaring the annotation was sufficient, but it seems that nothing in the current AS trunk actually does anything with that annotation, or at least not at a sufficiently early stage in the lifecycle to be useful.
The code in TestServiceControllerLifecycleCallback is generic, not specific to the TransactionManager service. IMO it should be present in the AS, but I don't see it. Do I need to include it in the TS side of the integration module? To my mind the functionality should really be provided via bootstrap-beans, so in the xml for the TransactionManager I can simply reference the ServiceLifecycle bean rather than having to declare it first. Or perhaps one of the existing beans already has this functionality? -
25. Re: migrating from ServiceMBeanSupport
alesj Jan 2, 2008 1:51 PM (in response to jhalliday)"jhalliday" wrote:
... but it seems that nothing in the current AS trunk actually does anything with that annotation, or at least not at a sufficiently early stage in the lifecycle to be useful.
IMO it should be present in the AS, but I don't see it.
What about this? ;-)
server\all\deployers\jboss-aop-jboss5.deployer\META-INF\jboss-aspect-library-beans.xml(16): class="org.jboss.system.microcontainer.jmx.ServiceControllerLifecycleCallback"
server\default\deployers\jboss-aop-jboss5.deployer\META-INF\jboss-aspect-library-beans.xml(16): class="org.jboss.system.microcontainer.jmx.ServiceControllerLifecycleCallback""jhalliday" wrote:
To my mind the functionality should really be provided via bootstrap-beans, so in the xml for the TransactionManager I can simply reference the ServiceLifecycle bean rather than having to declare it first. Or perhaps one of the existing beans already has this functionality?
Read Adrian's comment once again. ;-)
The problem is really when AOP kicks in.
Too late for bootstrap beans. -
26. Re: migrating from ServiceMBeanSupport
jhalliday Jan 2, 2008 2:21 PM (in response to jhalliday)Yes, I follow (but don't necessarily agree with) the argument that the TransactionManager should be in deploy, but given that we can't put it there in the short term we need an alternative solution.
Can the ServiceControllerLifecycleCallback stuff be moved such that it is available for use in the jboss-service.xml? To my mind it belongs not in the AOP deployer but in the bootstrap or early in the jboss-service.xml, so that services can make use of it. Otherwise as far as I can tell the TransactionManager is going to have to have its own duplicate of the same functionality, which seems less than elegant. -
27. Re: migrating from ServiceMBeanSupport
alesj Jan 2, 2008 3:04 PM (in response to jhalliday)"jhalliday" wrote:
Yes, I follow (but don't necessarily agree with) the argument that the TransactionManager should be in deploy, but given that we can't put it there in the short term we need an alternative solution.
I can port my test to be used in real use case.
I'll let you know when I'm done."jhalliday" wrote:
Can the ServiceControllerLifecycleCallback stuff be moved such that it is available for use in the jboss-service.xml? To my mind it belongs not in the AOP deployer but in the bootstrap or early in the jboss-service.xml, so that services can make use of it. Otherwise as far as I can tell the TransactionManager is going to have to have its own duplicate of the same functionality, which seems less than elegant.
SCLC as such is a plain bean.
It's just the AOP that uses it, in the most transparent way.
Perhaps we can use two instances of it - one for direct MBeanExport, the other one via AOP and @JMX lookup. -
28. Re: migrating from ServiceMBeanSupport
jhalliday Jan 2, 2008 3:29 PM (in response to jhalliday)Hmm yes, that would work. All i'm trying to avoid is duplicating the java code. Duplicating a bit of xml bothers me a lot less. From the sounds of things it would be feasible to declare a bean with class=org.jboss.system.microcontainer.jmx.ServiceControllerLifecycleCallback in the jboss-service.xml file and inject the legacy JMX kernel into it, then reference that in the TransactionManager bean xml?
-
29. Re: migrating from ServiceMBeanSupport
alesj Jan 2, 2008 3:44 PM (in response to jhalliday)"jhalliday" wrote:
From the sounds of things it would be feasible to declare a bean with class=org.jboss.system.microcontainer.jmx.ServiceControllerLifecycleCallback in the jboss-service.xml file and inject the legacy JMX kernel into it, then reference that in the TransactionManager bean xml?
Exactly.
This is what solves your problem:<bean name="MBeanExporter" class="org.jboss.system.microcontainer.jmx.ServiceControllerLifecycleCallback"> <property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property> </bean> <bean name="TransactionManager" class="org.jboss.tm.RealTransactionManager"> <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=TransactionManager", exposedInterface=org.jboss.test.system.controller.integration.support.MockTransactionManagerMBean.class, registerDirectly=true)</annotation> <property name="transactionTimeout">300</property> <property name="objectStoreDir">${jboss.server.data.dir}/tx-object-store</property> <install bean="MBeanExporter" method="install"> <parameter><inject fromContext="context"/></parameter> </install> <uninstall bean="MBeanExporter" method="uninstall"> <parameter><inject fromContext="context"/></parameter> </uninstall> </bean>
And since the AOP kicks in later, this bean won't be picked up twice for JMX registry - conclusion from Adrian's comment.