I replied to the other thread... http://www.nabble.com/Re%3A-How-to-enlarge-ActiveMQ%27S-capacity-of-concurrent--p6358828.html
On 9/12/06, Viali <[EMAIL PROTECTED]> wrote:
I confiugre and xml file for ActiveMQ, and create a broker using Xbean as followed: xbean.xml: <beans> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <broker useJmx="true" xmlns="http://activemq.org/config/1.0" > <persistenceAdapter> <journaledJDBC journalLogFiles="5" dataDirectory="./Data" /> </persistenceAdapter> <transportConnectors> <transportConnector uri="tcp://localhost:61616" /> </transportConnectors> </broker> </beans> Java Code for creating a broker: URI uri=new URI("xbean:xbean.xml"); BrokerService broker = BrokerFactory.createBroker(uri); broker.start(); Then, Write a message provider: public static class HelloWorldProducer implements Runnable { public void run() { try { // Create a ConnectionFactory ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); // Create a Connection Connection connection = connectionFactory.createConnection(); connection.start(); // Create a Session Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); // Create the destination (Topic or Queue) Destination destination = session.createQueue("TEST.FOO"); // Create a MessageProducer from the Session to the Topic or Queue MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.PERSISTENT); // Create a messages String text = "Hello world! From: " + Thread.currentThread().getName() + " : " + this.hashCode(); TextMessage message = session.createTextMessage(text); // Tell the producer to send the message System.out.println("Sent message: "+ message.hashCode() + " : " + Thread.currentThread().getName()); producer.send(message); // Clean up session.close(); connection.close(); } catch (Exception e) { e.printStackTrace(); } } } However, when I run the codes followed: for(int i=0;i<500;i++)//create 500 connections at the same time.. { thread(new HelloWorldProducer(), false); // Thread.sleep(300); // everything works fine if sleep. } Then some thread runs fine, but others not. I can see Exceptions happens: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:32) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:252) at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:165) at org.sigsit.ict.AppTest$HelloWorldProducer.run(AppTest.java:51) at java.lang.Thread.run(Unknown Source) Caused by: java.net.ConnectException: Connection refused: connect ..........balaballa.. -- View this message in context: http://www.nabble.com/How-to-enlarge-ActiveMQ%27S-capacity-of-concurrent--tf2258370.html#a6264416 Sent from the ActiveMQ - User forum at Nabble.com.
-- James ------- http://radio.weblogs.com/0112098/