-
1. Re: Add method to MDB for jmx/mbean?
rocken7 Mar 12, 2007 4:32 PM (in response to rocken7)My MDB class implements MessageListener, which already has default JMX lifecycle methods: the org.jboss.ejb3.ServiceDelegateWrapper.
There are activation properties well documented here:
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigJMSMessageListener
I tried adding the @Management tag to the MDB class, which does not affect anything.
Does the @MessageDriven tag on the MDB class make this impossible?
I tried forking off the management methods into an abstract class, then in the MDB class specify @Management(MyJMXBase.class) which blows b/c the MDB class needs to implement MessageListener (even tho my abstract class implements MessageListener):
ExceptioN:
unable to determine messagingType interface for MDB
So
I put @Management(MyJMXBase.class) tag on the MDB class (which extends MyJMXBase), implement MessageListener directly, and this does nothing.
What is needed to add a JMX operation (method) to an MDB?
I can't find any docs on @Management anyway, so it feels like i'm fishing ... -
2. Re: Add method to MDB for jmx/mbean?
rocken7 Mar 12, 2007 4:43 PM (in response to rocken7)Ok looks like i'll have to try out this approach:
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3978558
But then why is there a @Management tag, doesn't that eliminate the need for .sars etc. ? -
3. Re: Add method to MDB for jmx/mbean?
rocken7 Mar 12, 2007 8:18 PM (in response to rocken7)And how do I find the MDB instance in jndi? What would the jndi path be? I don't see it in the JNDIView ... How would I specify the jndi path for the MDB instance?
-
4. Re: Add method to MDB for jmx/mbean?
rocken7 Mar 12, 2007 8:33 PM (in response to rocken7)Ok I can insert the MDB via the @PostConstruct method, by binding to jndi, but that feels wrong, is there a way to specify the jndi?
-
5. Re: Add method to MDB for jmx/mbean?
rocken7 Mar 13, 2007 12:39 PM (in response to rocken7)Well the MDB is a SLSB, therefore kind of wrong to bind into jndi. So what I did was use an entity bean (cached) with configuration props and inject that into the MDB in order to manage the message queue. This will work pretty well.
And my jmx bean will set props (manage) on the entity configuration as well as evict it from the cache. -
6. Re: Add method to MDB for jmx/mbean?
rocken7 Mar 14, 2007 2:15 PM (in response to rocken7)So I did the JMX Mbean, and had a hell of a time figuring out how to get to an EntityManager from within the MBean. No resource injection works, why I have no idea, is this a bug?
@PersistenceContext did nothing, @Resource did nothing. No idea how to get that working. The @Management annotation is a mystery as well (but I digress).
Me thinks jboss/redhat need some serious document renewals, the documentation is worse than my GF's sense of direction.
Without the UserTransaction, jboss vomits NullPointer exceptions. All attempts to create the EntityManager using the factory failed as well.
Here is a related jira report:
http://jira.jboss.com/jira/browse/EJBTHREE-665;jsessionid=E296A2B1C1633F424959E377C8838B32?page=all
This was how I got it to work:UserTransaction tx = null; try { InitialContext ctx = new InitialContext(); tx = (UserTransaction) ctx.lookup("UserTransaction"); tx.begin(); EntityManager em = (EntityManager) ctx.lookup("java:/Myxdb"); Query q = em.createNamedQuery("MyXAdsProp.findByName"); q.setParameter("name", name); MyXAdsProp dap = (MyXAdsProp) q.getSingleResult(); if( dap.getValue() != null && !dap.getValue().equals(value)) { dap.setValue(value); } tx.commit(); return "OK"; } catch(Exception e) { if( tx.getStatus() == Status.STATUS_ACTIVE ) { tx.rollback(); } e.printStackTrace(); return new String(e.getMessage()); }