* DLQs are NOT enabled at the virtualhost level, we are testing recovery of the arguments
* that turned it on for this specific queue.
*/
public void testRecoveryOfQueueWithDLQ() throws Exception
{
JMXTestUtils jmxUtils = null;
try
{
jmxUtils = new JMXTestUtils(this, "guest", "guest");
jmxUtils.open();
}
catch (Exception e)
{
fail("Unable to establish JMX connection, test cannot proceed");
}
try
{
//verify the DLE exchange exists, has the expected type, and a single binding for the DLQ
ManagedExchange exchange = jmxUtils.getManagedExchange(QUEUE_WITH_DLQ_NAME + "_DLE");
assertEquals("Wrong exchange type", "fanout", exchange.getExchangeType());
TabularDataSupport bindings = (TabularDataSupport) exchange.bindings();
assertEquals(1, bindings.size());
for(Object o : bindings.values())
{
CompositeData binding = (CompositeData) o;
String bindingKey = (String) binding.get(ManagedExchange.BINDING_KEY);
String[] queueNames = (String[]) binding.get(ManagedExchange.QUEUE_NAMES);
//Because its a fanout exchange, we just return a single '*' key with all bound queues
assertEquals("unexpected binding key", "*", bindingKey);
assertEquals("unexpected number of queues bound", 1, queueNames.length);
assertEquals("unexpected queue name", QUEUE_WITH_DLQ_NAME + "_DLQ", queueNames[0]);
}
//verify the queue exists, has the expected alternate exchange and max delivery count
ManagedQueue queue = jmxUtils.getManagedQueue(QUEUE_WITH_DLQ_NAME);
assertEquals("Queue does not have the expected AlternateExchange", QUEUE_WITH_DLQ_NAME + "_DLE", queue.getAlternateExchange());
assertEquals("Unexpected maximum delivery count", Integer.valueOf(2), queue.getMaximumDeliveryCount());
ManagedQueue dlQqueue = jmxUtils.getManagedQueue(QUEUE_WITH_DLQ_NAME + "_DLQ");
assertNull("Queue should not have an AlternateExchange", dlQqueue.getAlternateExchange());
assertEquals("Unexpected maximum delivery count", Integer.valueOf(0), dlQqueue.getMaximumDeliveryCount());
String dlqDlqObjectNameString = jmxUtils.getQueueObjectNameString("test", QUEUE_WITH_DLQ_NAME + "_DLQ" + "_DLQ");
assertFalse("a DLQ should not exist for the DLQ itself", jmxUtils.doesManagedObjectExist(dlqDlqObjectNameString));
}
finally
{
jmxUtils.close();
}
}