activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1207231 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java
Date Mon, 28 Nov 2011 14:37:16 GMT
Author: gtully
Date: Mon Nov 28 14:37:15 2011
New Revision: 1207231

URL: http://svn.apache.org/viewvc?rev=1207231&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3454 - all the little performance test, non imperative

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java 
 (with props)

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java?rev=1207231&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java Mon
Nov 28 14:37:15 2011
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.bugs;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import junit.framework.TestCase;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AMQ3454Test extends TestCase {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AMQ3454Test.class);
+    private static final int MESSAGES_COUNT = 10000;
+
+    public void testSendWithLotsOfDestinations() throws Exception {
+        final BrokerService broker = new BrokerService();
+        broker.setPersistent(false);
+        broker.setUseJmx(false);
+        broker.setDeleteAllMessagesOnStartup(true);
+
+        broker.addConnector("tcp://localhost:0");
+
+        // populate a bunch of destinations, validate the impact on a call to send
+        ActiveMQDestination[] destinations = new ActiveMQDestination[MESSAGES_COUNT];
+        for (int idx = 0; idx < MESSAGES_COUNT; ++idx) {
+            destinations[idx] = new ActiveMQQueue(getDestinationName() + "-" + idx);
+        }
+        broker.setDestinations(destinations);
+        broker.start();
+
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(
+                broker.getTransportConnectors().get(0).getPublishableConnectString());
+        final Connection connection = factory.createConnection();
+        connection.start();
+
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(new ActiveMQQueue(getDestinationName()));
+
+        long start = System.currentTimeMillis();
+        for (int idx = 0; idx < MESSAGES_COUNT; ++idx) {
+            Message message = session.createTextMessage("" + idx);
+            producer.send(message);
+        }
+        LOG.info("Duration: " + (System.currentTimeMillis() - start) + " millis");
+        producer.close();
+        session.close();
+
+    }
+
+    protected String getDestinationName() {
+        return getClass().getName() + "." + getName();
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3454Test.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message