9 Replies Latest reply on Jul 18, 2002 12:31 PM by blairj

    MBean to start external services

    blairj

      My question is more of a design one. I am currently using JBoss 2.4.4 and I need to be able to start an external java app after JBoss starts (the app hooks into JNDI via RMI). And well my question is: Is a MBean appropiate to this situation (I also need to be able to restart the application from an EJB inorder to provide failover capabilities)? So any help / opinions are appreciated.

      Thanks
      blairj

        • 1. Re: MBean to start external services

          You can do whatever you like in an MBean.
          Not sure about the rest? An ejb is really for business
          logic not systems programming.

          Regards,
          Adrian

          • 2. Re: MBean to start external services
            marc.fleury

            Actually I will disagree with you there adrian, I think EJBs are wonderful system constructs :) failover, remoteness, threading, transactional.. hmmm nice system you got there

            For example the HTTPSession clustering was done leverage this

            • 3. Re: MBean to start external services

              Yes, mbeans can create ejbs to distribute state across
              a cluster and take advantage of all the other features
              provided by the container.

              I don't think blairj was talking about the same thing?

              Regards,
              Adrian

              • 4. Re: MBean to start external services
                blairj

                No actually I was thinking of being able to call the MBean from my EJB when I needed to restart the external services. I'm not sure if this is legal / available / etc. (sorry I am just learning about MBeans so I don't really know all of the limitations to them).

                Thanks,
                blairj

                • 5. Re: MBean to start external services
                  sgturner

                  Calling an MBean from an EJB is doable. Two ways to do it, but I don't know which is better.

                  1. Write an extra MBean that registers your MBean with Jn di. Then in EJB, get reference to MBean from Jndi.

                  2. In EJB, get reference to MBeanServer directly and use it to invoke a method on your MBean

                  Perhaps someone else has other suggestions or an opinion as to which of these 2 ways is best. I've done both. #1 was the hardest in terms of figuring out what to code.

                  • 6. Re: MBean to start external services

                    Invoking an MBean from an ejb is both possible and
                    valid.

                    I just don't think that using an ejb to monitor/restart
                    system functions is correct usage.

                    Regards,
                    Adrian

                    • 7. Re: MBean to start external services
                      blairj

                      This is an external service which connects to the jndi tree and sometimes the native code which it accesses burps and takes the JVM with it. So inorder to have failover capablities my EJBs need to be able to restart these external services when they need them. I know this probaly is not the best solution but it seems to be only one which conforms to the J2EE spec.

                      • 8. Re: MBean to start external services
                        schaefera

                        That is excatly what MEJB from JSR-77 is doing.

                        BUT be aware that a EJB using MBeans depends on the server implementation in how to find the MBeanServer so it isn't vendor-neutral anymore (at least as long as JMX is not part of J2EE).

                        Andy

                        • 9. Re: MBean to start external services
                          blairj

                          But as long as the container supports JMX it should not be a problem then right? The only two app servers which I have to worry about are JBoss 3 and WebSphere 5 ( it also supports JMX as I understand).