rejected = template.receive(dlq.getName());
n = 0;
while (n++ < 100 && rejected == null) {
Thread.sleep(100);
rejected = template.receive(dlq.getName());
}
assertTrue("Message did not arrive in DLQ", n < 100);
assertEquals("foo", new String(rejected.getBody()));
assertNotNull(failed.get());