14.3. Configuring the transport directly from the client side

This section shows how to configure a core ClientSessionFactory to connect with a server.
Connectors are used indirectly when configuring a core ClientSessionFactory to talk to a server. In this case, it is unnecessary to define a connector in the server-side configuration. Instead, create the parameters and configure the connector factory to be used by ClientSessionFactory.
The following ClientSessionFactory connects directly to the acceptor defined previously in this chapter. It uses the standard Netty TCP transport, and will attempt to connect on port 5446 to localhost (the default).
Map<String, Object> connectionParams = 
  new HashMap<String, Object>();
    
  connectionParams.put(
    org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, 
    5446
  );

TransportConfiguration transportConfiguration = 
  new TransportConfiguration(
    "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", 
    connectionParams
  );

ClientSessionFactory sessionFactory = 
  HornetQClient.createClientSessionFactory(transportConfiguration);

ClientSession session = sessionFactory.createSession(...);
For JMS, you can configure the JMS connection directly on the client side without defining a connector on the server side or a connection factory in JBOSS_DIST/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-jms.xml:
Map<String, Object> connectionParams = 
  new HashMap<String, Object>();

connectionParams.put(
  org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, 
  5446
);

TransportConfiguration transportConfiguration = 
  new TransportConfiguration(
    "org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", 
    connectionParams
  );

ConnectionFactory connectionFactory = 
  HornetQJMSClient.createConnectionFactory(transportConfiguration);

Connection jmsConnection = connectionFactory.createConnection();