activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-214 exception when sending 10k message
Date Tue, 26 Apr 2016 14:04:31 GMT
ARTEMIS-214 exception when sending 10k message


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/fcda12f9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/fcda12f9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/fcda12f9

Branch: refs/heads/master
Commit: fcda12f92c0cdccb495c697551d132811df88e7e
Parents: 5863726
Author: Howard Gao <howard.gao@gmail.com>
Authored: Mon Apr 25 22:13:18 2016 +0800
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Apr 26 10:04:24 2016 -0400

----------------------------------------------------------------------
 .../java/org/proton/plug/util/DeliveryUtil.java |  1 +
 .../amqp/jms/SendingAndReceivingTest.java       | 98 ++++++++++++++++++++
 2 files changed, 99 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fcda12f9/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/util/DeliveryUtil.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/util/DeliveryUtil.java
b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/util/DeliveryUtil.java
index 4c2272c..ae98891 100644
--- a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/util/DeliveryUtil.java
+++ b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/util/DeliveryUtil.java
@@ -30,6 +30,7 @@ public class DeliveryUtil {
       while ((count = receiver.recv(buffer.array(), buffer.arrayOffset() + buffer.writerIndex(),
buffer.writableBytes())) > 0) {
          // Increment the writer index by the number of bytes written into it while calling
recv.
          buffer.writerIndex(buffer.writerIndex() + count);
+         buffer.ensureWritable(count);
       }
       return buffer.writerIndex() - initial;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fcda12f9/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/jms/SendingAndReceivingTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/jms/SendingAndReceivingTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/jms/SendingAndReceivingTest.java
new file mode 100644
index 0000000..313ac84
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/jms/SendingAndReceivingTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.artemis.tests.integration.amqp.jms;
+
+import java.util.Random;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.qpid.jms.JmsConnectionFactory;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SendingAndReceivingTest extends ActiveMQTestBase {
+
+   private ActiveMQServer server;
+
+   @Before
+   public void setUp() throws Exception {
+      super.setUp();
+      server = createServer(true, true);
+      server.start();
+   }
+
+   @After
+   public void tearDown() throws Exception {
+      try {
+         server.stop();
+      }
+      finally {
+         super.tearDown();
+      }
+   }
+
+   //https://issues.apache.org/jira/browse/ARTEMIS-214
+   @Test
+   public void testSendingBigMessage() throws Exception {
+      Connection connection = null;
+      ConnectionFactory connectionFactory = new JmsConnectionFactory("amqp://localhost:61616");
+
+      try {
+         connection = connectionFactory.createConnection();
+         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Queue queue = session.createQueue("jms.queue.exampleQueue");
+         MessageProducer sender = session.createProducer(queue);
+
+         String body = createMessage(10240);
+         sender.send(session.createTextMessage(body));
+         connection.start();
+
+         MessageConsumer consumer = session.createConsumer(queue);
+         TextMessage m = (TextMessage) consumer.receive(5000);
+
+         Assert.assertEquals(body, m.getText());
+      }
+      finally {
+         if (connection != null) {
+            connection.close();
+         }
+      }
+   }
+
+   private static String createMessage(int messageSize) {
+      final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+      Random rnd = new Random();
+      StringBuilder sb = new StringBuilder((int) messageSize);
+      for (int j = 0; j < messageSize; j++ ) {
+         sb.append(AB.charAt(rnd.nextInt(AB.length())));
+      }
+      String body = sb.toString();
+      return body;
+   }
+
+}


Mime
View raw message