// send 2 messages on queue
producer.send(session.createMessage(false));
producer.send(session.createMessage(false));
QueueControl queueControl = createManagementControl(address, queue);
QueueControl deadLetterQueueControl = createManagementControl(deadLetterAddress, deadLetterQueue);
Assert.assertEquals(2, queueControl.getMessageCount());
// the message IDs are set on the server
Map<String, Object>[] messages = queueControl.listMessages(null);
Assert.assertEquals(2, messages.length);
long messageID = (Long)messages[0].get("messageID");
queueControl.setDeadLetterAddress(deadLetterAddress.toString());
Assert.assertEquals(0, deadLetterQueueControl.getMessageCount());
boolean movedToDeadLetterAddress = queueControl.sendMessageToDeadLetterAddress(messageID);
Assert.assertTrue(movedToDeadLetterAddress);
Assert.assertEquals(1, queueControl.getMessageCount());
Assert.assertEquals(1, deadLetterQueueControl.getMessageCount());
// check there is a single message to consume from queue
ManagementTestBase.consumeMessages(1, session, queue);
// check there is a single message to consume from deadletter queue