[jboss-user] [JBoss Messaging Users] - ClusteredConnectionFactory

roman.mandeleil@gmail.com do-not-reply at jboss.com
Fri Oct 2 11:29:39 EDT 2009


Hi, 

I try to cook load balancing through JMS connection factory here is two questions to the pros: 

1) When I use it from the stand alone it really works, which means it creates connection to each node in it's turn. The question is when I get the object - JBossConnectionFactory I see it encapsulates ClientClusteredConnectionFactoryDelegate object which is reasonable but  the data member supportLoadBalancing is false, the question is why ?

2) The second question is when I try the same stuff not from the stand alone to a server but from server to server it doesn't work the connection been created each time to one node despite the fact there is two nodes in the cluster, again the question is what can be the problem ?


Here is all the details: 

I am using JBoss 5.1 GA all -  configuration, two nodes - ports binding 02 and 03.



on the client here is the code that gets the factory and creates the connection: 


  | 	Connection connection = null;
  |         InitialContext initialContext = null;
  | 		
  |         
  |         Hashtable<String, String> jndiParameters = new Hashtable<String, String>();
  |         jndiParameters.put("java.naming.provider.url", "127.0.0.1:1300,127.0.0.1:1400");
  |         jndiParameters.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
  |         jndiParameters.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
  |         
  |         
  | 		initialContext = new InitialContext(jndiParameters);
  | 
  | 		Queue queue = (Queue) initialContext.lookup("/queue/DLQ");
  | 		
  | 		ConnectionFactory cf = (ConnectionFactory) initialContext
  | 				.lookup("/ClusteredConnectionFactory");
  |         
  |         for (Integer i = 0; true; i++) {
  | 			try {
  | 
  | 
  | 				connection = cf.createConnection();
  | 
  | 				Session session = connection.createSession(false,
  | 						Session.AUTO_ACKNOWLEDGE);
  | 				MessageProducer producer = session.createProducer(queue);
  | 
  | 				String myString = new String(i.toString());
  | 				ObjectMessage objectMessage = session.createObjectMessage(myString);
  | 				
  | 				producer.send(objectMessage);
  | 				
  | 			} catch (Throwable th){
  | 				
  | 				th.printStackTrace();
  | 				continue;
  | 				
  | 			} finally {
  | 				if (connection != null) {
  | 					connection.close();
  | 				}
  | 			}
  | 		}
  |      }        
  | 
  | 



on the server I use the same principle.


Thanks in advance 
Roman





View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4258436#4258436

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4258436



More information about the jboss-user mailing list