5 Replies Latest reply on Jun 13, 2008 4:55 AM by gary.c.chen

    Can JBoss Messaging uses direct method invocation while send

    gary.c.chen

      I am now using JBoss Messaging as a JMS server in my application and I don't use any Cluster feature now and this application is deployed on JBoss AS 4.2.2.GA. In my application I use JMS API to send messages and receive messages in a Servlet, that means the JMS client and JMS server are in the same JVM, as shown below :

      |-------------------------------------------|
      | JVM |
      | |
      | |---------------| |---------------| |
      | | Servlet 1 | | Servlet 2 | |
      | | | | | |
      | | |-----------| | | |-----------| | |
      | | | Sender | | | | Receiver | | |
      | | | Client | | | | Client | | |
      | | |-----------| | | |-----------| | |
      | | | | | /|\ | |
      | |------|--------| |-----|---------| |
      | | | |
      | | | |
      | |----- | |---| |
      | | | |
      | \|/ | |
      | |-------------------| |
      | | | |
      | | | |
      | | JMS Server | |
      | | | |
      | |-------------------| |
      | |
      |--------------------------------------------

      I know we can optimize the Send Cilent (or Receive Cilent) and JMS Server not to use Socket (TCP/IP) while sending (or receiving) messages in this case, for example JBoss MQ uses a JVM connection factory which JNDI name is java:/ConnectionFactory to make client JMS API uses direct method invocation while sending or receiving messages.

      Could you please tell me if there is any mechanism to achieve the optimize in this case ?
      And I know there is two connection factories which JNDI name are java:/ConnectionFactory and java:/XAConnectionFactory, are them play the same role as in JBoss MQ? We just use (look up) these connection factories and then we can send or receive messages using direct method invocation and we still using the JMS API in the application, is it right ? Or I can use another way ? Or the JBoss Messaging client will achieve the optimize automatic when it determine the JMS client and the JMS server is in the same JVM ? And how it determine ?
      I couldn't find my answer from the User Guide.

        • 1. Re: Can JBoss Messaging uses direct method invocation while
          gary.c.chen

          |---------------------------------------------|
          | JVM |
          | |
          | |---------------| |---------------| |
          | | Servlet 1 | | Servlet 2 | |
          | | | | | |
          | | |-----------| | | |-----------| | |
          | | | Sender | | | | Receiver | | |
          | | | Client | | | | Client | | |
          | | |-----------| | | |-----------| | |
          | | | | | /|\ | |
          | |-------|-------| |-------|-------| |
          | | | |
          | | | |
          | |-------| |-------| |
          | | | |
          | \|/ | |
          | |-------------------| |
          | | | |
          | | | |
          | | JMS Server | |
          | | | |
          | |-------------------| |
          | |
          |---------------------------------------------|

          • 2. Re: Can JBoss Messaging uses direct method invocation while
            timfox

            Yes, JBM will automatically use in vm optimisation if client and server are in same vm (and classloader).

            • 3. Re: Can JBoss Messaging uses direct method invocation while
              gary.c.chen

              En, could you please tell me how JBM determine client and server are in the same VM ?
              You know, in a Servlet we use JNDI as follow :

              Context ctx = new InitialContext();
              QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("java:/ConnectionFactory");

              and we don't use the JNDI URL property.
              I had ever developed Application Server before, in our Application Server, we used the JNDI URL property to determine the JNDI lookup action is inside the server VM or outside, according to this we return a ConnectionFactory that it's created Connection used direct method invocation or used Socket.
              So I am very interesting in how JBM achieve the optimisation. Like the above I describe ?

              And you said the client and the server must in the same VM and loaded by the same ClassLoader, so JBM can do the optimisation, is that right ?

              And we know that the Servlet class and the JMS Server class are not loaded by the same ClassLoader.

              • 4. Re: Can JBoss Messaging uses direct method invocation while
                timfox

                This is handled by JBoss Remoting, not JBM.

                I believe they use statics to identify whether clients and servers are in same classloader.

                • 5. Re: Can JBoss Messaging uses direct method invocation while
                  gary.c.chen

                  en, I see, may be the client and the server have the same parent ClassLoader so they are in the same ClassLoader.