use of org.apache.activemq.util.ProducerThread in project activemq-artemis by apache.
the class JobSchedulerBrokerShutdownTest method testSchedule.
public void testSchedule() throws Exception {
Connection connection = createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
final long time = 1000;
ProducerThread producer = new ProducerThread(session, destination) {
@Override
protected Message createMessage(int i) throws Exception {
Message message = super.createMessage(i);
message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time);
return message;
}
};
producer.setMessageCount(200);
producer.setDaemon(true);
producer.start();
Thread.sleep(5000);
}
use of org.apache.activemq.util.ProducerThread in project activemq-artemis by apache.
the class JobSchedulerStoreUsageTest method testJmx.
public void testJmx() throws Exception {
LOG.info("Initial scheduler usage: {}", broker.getAdminView().getJobSchedulerStorePercentUsage());
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
Connection conn = factory.createConnection();
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination dest = sess.createQueue(this.getClass().getName());
final ProducerThread producer = new ProducerThread(sess, dest) {
@Override
protected Message createMessage(int i) throws Exception {
Message message = super.createMessage(i);
message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, WAIT_TIME_MILLS / 2);
return message;
}
};
producer.setMessageCount(100);
producer.start();
assertEquals(7 * 1024, broker.getAdminView().getJobSchedulerStoreLimit());
// wait for the producer to block
Thread.sleep(WAIT_TIME_MILLS / 2);
assertTrue(broker.getAdminView().getJobSchedulerStorePercentUsage() > 100);
broker.getAdminView().setJobSchedulerStoreLimit(1024 * 1024 * 33);
Thread.sleep(WAIT_TIME_MILLS);
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return producer.getSentCount() == producer.getMessageCount();
}
}, WAIT_TIME_MILLS * 2);
assertEquals("Producer didn't send all messages", producer.getMessageCount(), producer.getSentCount());
LOG.info("Final scheduler usage: {}", broker.getAdminView().getJobSchedulerStorePercentUsage());
assertTrue(broker.getAdminView().getJobSchedulerStorePercentUsage() < 100);
}
use of org.apache.activemq.util.ProducerThread in project activemq-artemis by apache.
the class StoreUsageTest method testJmx.
public void testJmx() throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
Connection conn = factory.createConnection();
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination dest = sess.createQueue(this.getClass().getName());
final ProducerThread producer = new ProducerThread(sess, dest);
producer.start();
// wait for the producer to block
Thread.sleep(WAIT_TIME_MILLS / 2);
broker.getAdminView().setStoreLimit(1024 * 1024);
Thread.sleep(WAIT_TIME_MILLS);
Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return producer.getSentCount() == producer.getMessageCount();
}
}, WAIT_TIME_MILLS * 2);
assertEquals("Producer didn't send all messages", producer.getMessageCount(), producer.getSentCount());
}
Aggregations