Hi Mahesh, we done something like that in v232 (do not use 3.0 currently). But with limits: - we use only our own defined JMX attributes, we do not use any of the James JMX attributes or methods. - I am not sure, but I think we were not able to access the james jmx attributes when we do this. - We have not been able to get too much runtime information from James, cause most things are "private", or maybe we did not search long enough. - But we do not need the James runtime information. - We use a mailet to do JMX, but a mailet is limited in access, so there should be a other way to extend this if you need James Runtime information. - We use some off the attributes we could have access to, inside the MailetContext and the Mailet. - We used the config file (wrote a JamesConfigFileParser, a XML Parser) to find the output directories. The is because the Mailet could not get access to that java classes. - We are interested in the "mails", not in "James". Questions like "how many mails have been handled?". A Mailet could answer that.
- We do not "1. List the users", cause we do not have users. - We do "2. List the number of files in the Inbox/Error folder", but only by parsing config.xml file and listing directories found there. - We do not "3. Move files from one folder to another", we never tried. Keep in mind that James need to run as root to get file access to all directories. This may be not the best way to do that, but we had the mailet before, handling EVERY mail. So we just extended it. There is much more going on in this mailet, so it has not been the aim to offer a JMX Mailet. But you may consider this. If it is enough to you, to get MailetContext and Mailet Informations, than this may be a solutions. What we done: We wrote a mailet (extends org.apache.mailet.base.GenericMailet), which is called every time. This mailet does nothing with the mail, it just counts the number of mails handled, number of mails failed, the last state, last error message. We offer some more application logic using JMX(like the state of connected signature smartcards) but this is not of interest here. When the mailet starts it registers it's mbean. public class MyMailet extends org.apache.mailet.base.GenericMailet { ... private void registerMBean() { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mbeanName = null; // The MBean needs to access this mailet. Because there is nothing // like a mailet registry, we must offer the reference by // creation time. MyMXBeanImpl secureMailMBean = new MyMXBeanImpl (this); mbeanName = new ObjectName("MyMailet:name=MyMailInformation "); mbs.registerMBean(secureMailMBean, mbeanName); Log.info("MBean registered: " + mbeanName.getCanonicalName()); } catch (JMException e) { Log.severe(e.getLocalizedMessage()); // just ignore if we could not register } catch (NullPointerException e) { Log.severe(e.getLocalizedMessage()); // just ignore if we could not register } } ... } public class MyMXBeanImpl implements MyMXBean { private final MailetContext context; public MyMXBeanImpl(JPACodeExitMailet mailet) { this.mailet = mailet; if (mailet != null) { this.context = mailet.getMailetContext(); } else { this.context = null; } } } public interface MyMXBean { public void createLogEntry(String msg); ... } You may need to start james with JMX option (phoenix.sh): export PHOENIX_JVM_OPTS="-Dcom.sun.management.jmxremote.port=22201 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" In config.xml the mailet is configured to get called every time when a mail comes in: <processor name="root"> ... <mailet match="All" class="JPACodeExitMailet"> </mailet> ... </processor> It would be nice if you could share your solution, if you are allowed to. It would be of interest in finding the best way to handle this. Best Regards, Bernd -----Ursprüngliche Nachricht----- Von: Mahesh Sivarama Pillai [mailto:srm...@gmail.com] Gesendet: Mittwoch, 6. August 2014 08:02 An: James Users List Betreff: Extend JAMES 2.3.2 JMX Hi, Can we extend the JMX capabilities of JAMES by adding more MBeans ? The capabilities I wanted to start with is; 1. List the users 2. List the number of files in the Inbox/Error folder etc. 3. Move files from one folder to another Have someone done similar things ? Please share your thoughts. Thanks Mahesh
smime.p7s
Description: S/MIME Cryptographic Signature