Client side load balancing
1117866v Oct 29, 2013 5:34 PMI am using jboss 6.0.1 AS, with hornetQ instance 2.2.24. I have a 2 node standalone cluster.
I have the following hornetQ configuration :
<outbound-socket-binding name="jboss-node-1-jms">
<remote-destination host="jboss-node1" port="5445"/>
</outbound-socket-binding>
<outbound-socket-binding name="jboss-node-2-jms">
<remote-destination host="jboss-node2" port="5445"/>
</outbound-socket-binding>
<connectors>
<netty-connector name="netty" socket-binding="messaging"/>
<netty-connector name="netty-throughput" socket-binding="messaging-throughput">
<param key="batch-delay" value="50"/>
</netty-connector>
<netty-connector name="netty-jboss-node-1" socket-binding="jboss-node-1-jms"/>
<netty-connector name="netty-jboss-node-2" socket-binding="jboss-node-2-jms"/>
<in-vm-connector name="in-vm" server-id="0"/>
</connectors>
<pooled-connection-factory name="NodeXAConnectionFactory">
<transaction mode="xa"/>
<connectors>
<connector-ref connector-name="netty-jboss-node-1"/>
<connector-ref connector-name="netty-jboss-node-2"/>
</connectors>
<entries>
<entry name="java:/XANodeRemoteConnectionFactory"/>
</entries>
</pooled-connection-factory>
my client code runs inside a stateless session bean is as follow :
InitialContext context = new InitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup( "java:/XANodeRemoteConnectionFactory" );
while (i < 1000) {
Connection connection = connectionFactory.createConnection( "admin", "123123" );
QueueSession session = (QueueSession) connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(TEST_QUEUE);
QueueSender sender = session.createSender(queue);
sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TextMessage jmsMessage = session.createTextMessage("Message number " + i++);
sender.send(jmsMessage);
if (session != null)
session.close();
if (sender != null)
sender.close();
}
Help me understand, why is the message distribution not 50% node1 and other 50% node2. I see the jboss-cli by default selects a roundrobin policy for the Pooled-Connection-Factory? What am I missing? or is that sessions dont know about the nodes available?