2 Replies Latest reply on Sep 13, 2008 8:15 AM by timfox

    How do you get JBossConnectionFactory to connect to a remote

    bbarlow

      I am trying to migrate a straight Java SE app from ActiveMQ to JBoss Messaging. This app creates a JMS ConnectionFactory to a JMS server on a remote machine. I would expect to use code along the lines of:

      connectionFactory = new JBossConnectionFactory("tcp://remotemachine.faraway.com:someport");
      connection = connectionFactory.createConnection();
      connection.start();
      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      destination = session.createQueue("MyQueue");
      


      etc. However, there doesn't appear to be any constructor for JBossConnectionFactory that does this. Am I using the wrong approach? Help appreciated.

        • 1. Re: How do you get JBossConnectionFactory to connect to a re
          peterj

          Try this:

          Context initial = new InitialContext();
          ConnectionFactory cf = (ConnectionFactory)initial.lookup("ConnectionFactory");

          where jndi.properties contains:

          java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
          java.naming.provider.url=jnp://remotemachine.faraway.com:1099
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

          • 2. Re: How do you get JBossConnectionFactory to connect to a re
            timfox

            The standard way in JMS to get a connection factory is to look it up from JNDI (see JMS spec).

            ActiveMQ is different in that it also allows you to instantiate one directly which is what you have done in the past.

            JBM 1.x does not support direct instantiation of connection factories, but JBM 2.0 does.