sess2.recover();
}
//At this point all the messages have been delivered exactly MAX_DELIVERIES times
Message m = cons.receive(1000);
assertNull(m);
//Now should be in default dlq
MessageConsumer cons3 = sess.createConsumer(defaultDLQ);
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons3.receive(1000);
assertNotNull(tm);
assertEquals("Message:" + i, tm.getText());
}
conn.close();
}
{
//Now try with overriding the default dlq
conn = cf.createConnection();
ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "DLQ", overrideDLQObjectName);
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(testQueue);
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess.createTextMessage("Message:" + i);
prod.send(tm);
}
Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer cons = sess2.createConsumer(testQueue);
conn.start();
for (int i = 0; i < MAX_DELIVERIES; i++)
{
for (int j = 0; j < NUM_MESSAGES; j++)
{
TextMessage tm = (TextMessage)cons.receive(1000);
assertNotNull(tm);
assertEquals("Message:" + j, tm.getText());
}
sess2.recover();
}
//At this point all the messages have been delivered exactly MAX_DELIVERIES times
Message m = cons.receive(1000);
assertNull(m);
//Now should be in override dlq