14.2. Understanding Connectors

Where acceptors are used on the server to define how we accept connections, connectors are used by a client to define how it connects to a server. Acceptors and Connectors are defined in the <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml file:
<connector name="netty">
  <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
  <param key="host" value="${jboss.bind.address:localhost}"/>
  <param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</connector>
Connectors can be defined inside a <connectors> element. Multiple connectors can be defined in the same <connectors> element. There is no upper limit to the number of connectors per server.
Although connectors are used by the client, they are defined on the server for a number of reasons:
  • Sometimes the server acts as a client itself when it connects to another server, for example when one server is bridged to another, or when a server takes part in a cluster. In these cases the server needs to know how to connect to other servers. This is defined by connectors.
  • If JMS and the server-side JMS service are used to instantiate JMS ConnectionFactory instances and bind them in JNDI, the JMS service needs to know which server the HornetQConnectionFactory will create connections to at the connection factory's creation.
    This is defined by the <connector-ref> element in the JBOSS_DIST/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-jms.xml file on the server side. The following snippet from a hornetq-jms.xml file shows a JMS connection factory that references the netty connector defined in the <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml file:
    <connection-factory name="NettyConnectionFactory">
        <connectors>
           <connector-ref connector-name="netty"/>
        </connectors>
        <entries>
            <entry name="/ConnectionFactory"/>
            <entry name="/XAConnectionFactory"/>
        </entries>
    </connection-factory>