ClientMessage msg = session.createMessage(false);
msg.putIntProperty("count", i);
producer.send(msg);
}
ClientConsumer cons = session.createConsumer(queue);
session.start();
LinkedList<ClientMessage> msgs = new LinkedList<ClientMessage>();
for (int i = 0; i < 50; i++)
{
ClientMessage msg = cons.receive(1000);
msgs.add(msg);
}
QueueControl queueControl = createManagementControl(address, queue);
Assert.assertEquals(100, queueControl.getMessageCount());
// the message IDs are set on the server
Map<String, Object>[] messages = queueControl.listMessages(null);
Assert.assertEquals(50, messages.length);
assertEquals(50, ((Number)messages[0].get("count")).intValue());
long messageID = (Long)messages[0].get("messageID");
// delete 1st message
boolean deleted = queueControl.removeMessage(messageID);
Assert.assertTrue(deleted);
Assert.assertEquals(99, queueControl.getMessageCount());
cons.close();
// check there is a single message to consume from queue
ManagementTestBase.consumeMessages(99, session, queue);
session.deleteQueue(queue);