use of org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper in project activemq-artemis by apache.
the class BrokerTest method testQueueAckRemovesMessage.
public void testQueueAckRemovesMessage() throws Exception {
// Start a producer and consumer
StubConnection connection = createConnection();
ConnectionInfo connectionInfo = createConnectionInfo();
SessionInfo sessionInfo = createSessionInfo(connectionInfo);
ProducerInfo producerInfo = createProducerInfo(sessionInfo);
connection.send(connectionInfo);
connection.send(sessionInfo);
connection.send(producerInfo);
destination = createDestinationInfo(connection, connectionInfo, destinationType);
Message message1 = createMessage(producerInfo, destination, deliveryMode);
Message message2 = createMessage(producerInfo, destination, deliveryMode);
connection.send(message1);
connection.send(message2);
// Make sure the message was delivered.
ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
connection.request(consumerInfo);
Message m = receiveMessage(connection);
assertNotNull(m);
assertEquals(m.getMessageId(), message1.getMessageId());
ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
long messageCount = wrapper.getAMQueueMessageCount(destination);
assertTrue(messageCount == 2);
connection.send(createAck(consumerInfo, m, 1, MessageAck.DELIVERED_ACK_TYPE));
messageCount = wrapper.getAMQueueMessageCount(destination);
assertTrue(messageCount == 2);
connection.send(createAck(consumerInfo, m, 1, MessageAck.STANDARD_ACK_TYPE));
// give some time for broker to count down
Thread.sleep(2000);
messageCount = wrapper.getAMQueueMessageCount(destination);
assertTrue(messageCount == 1);
}
use of org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper in project activemq-artemis by apache.
the class BrokerService method makeSureDestinationExists.
public void makeSureDestinationExists(ActiveMQDestination activemqDestination) throws Exception {
ArtemisBrokerWrapper hqBroker = (ArtemisBrokerWrapper) this.broker;
// it can be null
if (activemqDestination == null) {
return;
}
if (activemqDestination.isQueue()) {
String qname = activemqDestination.getPhysicalName();
System.out.println("physical name: " + qname);
hqBroker.makeSureQueueExists(qname);
}
}
use of org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper in project activemq-artemis by apache.
the class JMSConsumerTest method createQueueControl.
private QueueControl createQueueControl(String destName) throws Exception {
ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
MBeanServer beanServer = wrapper.getMbeanServer();
SimpleString address = new SimpleString(destName);
ObjectName objName = ObjectNameBuilder.DEFAULT.getQueueObjectName(address, address, RoutingType.ANYCAST);
return MBeanServerInvocationHandler.newProxyInstance(beanServer, objName, QueueControl.class, false);
}
use of org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper in project activemq-artemis by apache.
the class RemoveDestinationTest method destinationPresentInAdminView.
private boolean destinationPresentInAdminView(ActiveMQTopic amqTopic) throws Exception {
boolean found = false;
ArtemisBrokerWrapper wrapper = (ArtemisBrokerWrapper) broker.getBroker();
PostOffice po = wrapper.getServer().getPostOffice();
Set<SimpleString> addressSet = po.getAddresses();
Iterator<SimpleString> iter = addressSet.iterator();
String addressToFind = amqTopic.getPhysicalName();
while (iter.hasNext()) {
if (addressToFind.equals(iter.next().toString())) {
found = true;
break;
}
}
return found;
}
use of org.apache.activemq.broker.artemiswrapper.ArtemisBrokerWrapper in project activemq-artemis by apache.
the class OptimizedAckTest method testReceivedMessageNotInFlightAfterScheduledAckFires.
public void testReceivedMessageNotInFlightAfterScheduledAckFires() throws Exception {
connection.setOptimizedAckScheduledAckInterval(TimeUnit.SECONDS.toMillis(10));
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("test");
MessageProducer producer = session.createProducer(queue);
for (int i = 0; i < 10; i++) {
producer.send(session.createTextMessage("Hello" + i));
}
MessageConsumer consumer = session.createConsumer(queue);
ArtemisBrokerWrapper broker = (ArtemisBrokerWrapper) ArtemisBrokerHelper.getBroker().getBroker();
Binding binding = broker.getServer().getPostOffice().getBinding(new SimpleString("test"));
final QueueImpl coreQueue = (QueueImpl) binding.getBindable();
assertTrue("prefetch full", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 10 == coreQueue.getDeliveringCount();
}
}));
for (int i = 0; i < 6; i++) {
javax.jms.Message msg = consumer.receive(4000);
assertNotNull(msg);
assertEquals("all prefetch is still in flight: " + i, 10, coreQueue.getDeliveringCount());
}
for (int i = 6; i < 10; i++) {
javax.jms.Message msg = consumer.receive(4000);
assertNotNull(msg);
assertTrue("most are acked but 3 remain", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return 3 == coreQueue.getDeliveringCount();
}
}));
}
assertTrue("After delay the scheduled ack should ack all inflight.", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
LOG.info("inflight count: " + coreQueue.getDeliveringCount());
return 0 == coreQueue.getDeliveringCount();
}
}));
}
Aggregations