3 Replies Latest reply on Sep 23, 2013 4:54 AM by ybxiang.china

    How to send mail to notify an app deployment?

    rodrigo.uchoa

      Hi everyone!

       

      I know this is a sort of strange need, but hey..  Life is not perfect

       

      The thing is, I have a JBoss AS 7.1.3 (EAP 6.0.1) running and I was wondering if it's possible to make it send notification emails each time any application is deployed/undeployed. From what I know from previous JBoss versions, this could be achieved using MBeans, but it seems that JBoss 7 doesn't support JMX MBeans anymore.

       

      Any idea will be appreciated.

        • 1. Re: How to send mail to notify an app deployment?
          ybxiang.china

          why NOT send email/JMS by yourself in your core service?

          It's controllable!

           

          For example:

           

          @Local(ICoreService.class)

          @Singleton

          @Startup

          public class CoreService implements ICoreService{

              ...  

              @PersistenceContext

              private EntityManager em;

            

              @PostConstruct

              public void start() throws Exception {

                  log.info(ServerConstants.SERVICE_STARTING_FLAG);

                 //send email or JMS here

                  log.info(ServerConstants.SERVICE_STARTED_FLAG);

              }

            

              @PreDestroy

              public void destroy(){

                  log.info(ServerConstants.SERVICE_DESTROYING_FLAG);

                  //send email or JMS here

                  log.info(ServerConstants.SERVICE_DESTROYED_FLAG);

              }

          }

          • 2. Re: How to send mail to notify an app deployment?
            ybxiang.china
            • 3. Re: How to send mail to notify an app deployment?
              ybxiang.china

              it seems that JBoss 7 doesn't support JMX MBeans anymore.

              ~~~~~Are you sure?

               

               

              I can flush JAAS cache through JMX:

               

              @RolesAllowed({KnownJaasRoles.ADMINISTRATOR})

                  public void flushJaasCache(String securityDomain) {

                 try {
                 javax.management.MBeanServerConnection mbeanServerConnection
                 = java.lang.management.ManagementFactory
                 .getPlatformMBeanServer();
                 javax.management.ObjectName mbeanName = new javax.management.ObjectName(
                 "jboss.as:subsystem=security,security-domain="
                 + securityDomain);
                 mbeanServerConnection.invoke(mbeanName, "flushCache", null, null);
                 } catch (Exception e) {
                 throw new SecurityException(e);
                 }

                  }