Sun GlassFish Message Queue 4.4 Developer's Guide for Java Clients

Creating a Direct Connection to an Embedded Broker

Once an embedded broker has been started, you can create direct connections to it from the client in which it is embedded. To do so, you create a connection as you would with an ordinary broker, but you specify mq://localhost/direct as broker address in the connection factory. For example:

com.sun.messaging.ConnectionFactory cf = new com.sun.messaging.ConnectionFactory();
cf.setProperty(ConnectionConfiguration.imqAddressList, "mq://localhost/direct");
Connection connection = cf.createConnection();