7 Replies Latest reply on Aug 25, 2002 6:21 PM by Juha Lindfors

    remote calls to mbeans

    garyg Novice

      Here's what I'm trying to do. I have stand-alone client programs running on remote machines that I use to create a remote queue during runtime. I created them programmaticlly just like they are in the docs in figure 6.40 when I was using 2.4.4, but using queues rather than topics (http://www.jboss.org/online-manual/HTML/ch06s07.html) . But now that I'm using 3.0.1, I understood this was done using mbeans and not sure what to do next.

      So here's what I've done so far. I have an MBean interface and implementation based on the ServiceMBean Interface and ServiceMBeanSupport class (as below), a simplest of examples I'm trying to learn with. I guess I'm going to just pick a *-services.xml file (since 3.0.1 doesnt' have the jboss.jcml) to put the mbean tags in.

      Is there example code anywhere of a remote client to make calls to this mbean?

      Any help/advice/suggestions to guide me through much appreciated. Docs on this are a little sparse.

      --- MyQueue.java

      public class MyQueue extends org.jboss.util.ServiceMBeanSupport
      implements MyQueueMBean
      {
      private boolean started;
      private String queueName;

      public boolean createQueue() {
      System.out.println("creating queue in MBean ...........");

      if (started)
      System.out.println("creating queue in started MBean ...........");
      else
      System.out.println("can't create, MBean not started! ...........");

      return true;
      }

      public String getName() {
      return "MyQueue:" + queueName;
      }

      public void startService()() throws Exception {
      started = true;
      System.out.println("starting MBean ...........");
      }

      public void stopService() throws Exception {
      started = false;
      System.out.println("stoping MBean ...........");
      }
      }

      --- MyQueueMBean.java

      public interface MyQueueMBean extends org.jboss.util.ServiceMBean
      {
      public void start() throws Exception;
      public void stop() throws Exception;

      public boolean createQueue() throws Exception;
      }




        • 1. Re: remote calls to mbeans
          Juha Lindfors Master

          Yes, search the forum or read through the quick start guide.

          -- Juha

          • 2. Re: remote calls to mbeans
            garyg Novice

            :P

            • 3. Re: remote calls to mbeans
              Juha Lindfors Master

              come on, almost every other question on this forum is about how to use the RMI connector...

              • 4. Re: remote calls to mbeans
                garyg Novice

                Heh, ok, I though the mention of "sparse docs" would answer your first reply and the reference I gave in the old docs would clearly state it's not RMI. I'll be more clear.

                In 2.4.4 I did this via http and can't find it's equal in 3.0.1 and every reply I get sort of dodges the yes or no it works and if so, some hint on how. If http does work, that's ideal as I'd like to communicate to the mbeans across tcp/ip domains. If not, I'll have to find the RMI way and leave the feature that relies on http out of my stuff till it does come around.

                Sorry if I sound like I'm losing it, but I almost am at a few weeks of firing off posts at different angles and dozens of replies with nothing really to say.

                Thanks for taking the time.

                • 5. Re: remote calls to mbeans
                  Adrian Brock Master

                  You can do it from any web client

                  http://127.0.0.1:8080/jmx-console/HtmlAdaptor?
                  action=invokeOpByName&
                  name=jboss.mq%3Aservice%3DDestinationManager&
                  methodName=createQueue&
                  argType=java.lang.String&arg=blah&
                  argType=java.lang.String&arg=queue/blah

                  This creates a queue called "blah" bound at
                  "queue/blah" within jndi.

                  You probably want to configure some security for this.

                  Regards,
                  Adrian

                  • 6. Re: remote calls to mbeans
                    garyg Novice

                    Big thnxs, that's what I had been trying to construct ... and it's back to working like normal.

                    So now that I had about 3/4 of the way learned and implemented an MBean (still not working, but close I'm sure), ...

                    Are there any big advantages of using an RMI Adaptor over an HTML adaptor?

                    I did http because I've got a few solutions that have agents over separate domains and needed a way to get through the firewalls.

                    Thanks again, exactly what I was looking for.

                    • 7. Re: remote calls to mbeans
                      Juha Lindfors Master

                      AFAIR, the current RMI adaptor uses anon ports so that's going to be problem for any firewall setup (I'm not looking at the code so could remember wrong tho), so you need to tweak the code abit to allow a config of specific port for exporting the remote object for firewalls (and you still need to punch a hole for that port).

                      There's some mechanism in RMI to tunnel thru HTTP but I haven't looked into that.

                      Also, you could just use a simple SOAP connector (download an example from my book sources that uses GLUE), thats pure HTTP. The advantage of connectors such as RMI or SOAP is you get the MBeanServer API on the client side (which is alot more stable than relying on the HTTP requests of a specific HTML adaptor).

                      HTH

                      -- Juha