mirror of https://github.com/apache/activemq.git
use a bytes message, I think default encoding may the the root cause of variation of message size and limit checks on ci boxes
This commit is contained in:
parent
216626569a
commit
35115fece7
|
@ -17,6 +17,7 @@
|
||||||
package org.apache.activemq.usecases;
|
package org.apache.activemq.usecases;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import javax.jms.BytesMessage;
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
import javax.jms.Message;
|
import javax.jms.Message;
|
||||||
import javax.jms.MessageConsumer;
|
import javax.jms.MessageConsumer;
|
||||||
|
@ -44,7 +45,7 @@ import org.slf4j.LoggerFactory;
|
||||||
@RunWith(value = Parameterized.class)
|
@RunWith(value = Parameterized.class)
|
||||||
public class MemoryLimitTest extends TestSupport {
|
public class MemoryLimitTest extends TestSupport {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MemoryLimitTest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MemoryLimitTest.class);
|
||||||
final String payload = new String(new byte[10 * 1024]); //10KB
|
final byte[] payload = new byte[10 * 1024]; //10KB
|
||||||
protected BrokerService broker;
|
protected BrokerService broker;
|
||||||
|
|
||||||
@Parameterized.Parameter
|
@Parameterized.Parameter
|
||||||
|
@ -104,7 +105,9 @@ public class MemoryLimitTest extends TestSupport {
|
||||||
final ProducerThread producer = new ProducerThread(sess, queue) {
|
final ProducerThread producer = new ProducerThread(sess, queue) {
|
||||||
@Override
|
@Override
|
||||||
protected Message createMessage(int i) throws Exception {
|
protected Message createMessage(int i) throws Exception {
|
||||||
return sess.createTextMessage(payload + "::" + i);
|
BytesMessage bytesMessage = sess.createBytesMessage();
|
||||||
|
bytesMessage.writeBytes(payload);
|
||||||
|
return bytesMessage;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
producer.setMessageCount(2000);
|
producer.setMessageCount(2000);
|
||||||
|
@ -132,12 +135,12 @@ public class MemoryLimitTest extends TestSupport {
|
||||||
@Override
|
@Override
|
||||||
public boolean isSatisified() throws Exception {
|
public boolean isSatisified() throws Exception {
|
||||||
LOG.info("Destination usage: " + dest.getMemoryUsage());
|
LOG.info("Destination usage: " + dest.getMemoryUsage());
|
||||||
return dest.getMemoryUsage().getPercentUsage() >= 470;
|
return dest.getMemoryUsage().getPercentUsage() >= 200;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
LOG.info("Broker usage: " + broker.getSystemUsage().getMemoryUsage());
|
LOG.info("Broker usage: " + broker.getSystemUsage().getMemoryUsage());
|
||||||
assertTrue(broker.getSystemUsage().getMemoryUsage().getPercentUsage() >= 470);
|
assertTrue(broker.getSystemUsage().getMemoryUsage().getPercentUsage() >= 200);
|
||||||
|
|
||||||
// let's make sure we can consume all messages
|
// let's make sure we can consume all messages
|
||||||
for (int i = 1; i < 2000; i++) {
|
for (int i = 1; i < 2000; i++) {
|
||||||
|
|
Loading…
Reference in New Issue