return;
}
// add an NACKING receiver to the channel
SimpleReceiver r = new SimpleReceiver("NackingReceiver", SimpleReceiver.ACCEPTING);
assertTrue(queue.add(r));
SimpleDeliveryObserver observer = new SimpleDeliveryObserver();
MessageReference[] refs = new MessageReference[NUMBER_OF_MESSAGES];
for(int i = 0; i < NUMBER_OF_MESSAGES; i++)
{
refs[i] = createReference(i, true, "payload" + i);
// non-transacted send, reliable message, multiple messages
Delivery delivery = queue.handle(observer, refs[i], null);
assertTrue(delivery.isDone());
}
assertEquals(NUMBER_OF_MESSAGES, queue.getDeliveringCount());
assertEqualSets(refs, r.getMessages());
Transaction tx = tr.createTransaction();
for(Iterator i = r.getMessages().iterator(); i.hasNext();)
{
Message ackm = (Message)i.next();
// transacted acknowledgment
r.acknowledge(ackm, tx);
}
assertEquals(NUMBER_OF_MESSAGES, queue.getDeliveringCount());
tx.rollback();
assertEquals(NUMBER_OF_MESSAGES, queue.getDeliveringCount());
// acknowledge non-transactionally
for(Iterator i = r.getMessages().iterator(); i.hasNext();)
{
Message ackm = (Message)i.next();
// non-transacted acknowledgment
r.acknowledge(ackm, null);
}
assertTrue(queue.browse().isEmpty());
}