50475048504950505051505250535054505550565057
for(Iterator i = r.getMessages().iterator(); i.hasNext();) { Message ackm = (Message)i.next(); // non-transacted acknowledgment r.acknowledge(ackm, null); } assertTrue(queue.browse().isEmpty()); }
50925093509450955096509750985099510051015102
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.commit();
51415142514351445145514651475148514951505151
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();
51555156515751585159516051615162516351645165
// 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()); }
52035204520552065207520852095210521152125213
assertEquals(1, acknowledging.size()); Message ackm = (Message)acknowledging.get(0); assertEquals(0, ackm.getMessageID()); // non-transacted acknowledgment r.acknowledge(ackm, null); assertTrue(queue.browse().isEmpty()); } /**
52325233523452355236523752385239524052415242
queue.handle(observer, ref, null); Message ackm = (Message)r.getMessages().get(0); // acknowledge once r.acknowledge(ackm, null); assertTrue(queue.browse().isEmpty()); // acknowledge twice try
52395240524152425243524452455246524752485249
assertTrue(queue.browse().isEmpty()); // acknowledge twice try { r.acknowledge(ackm, null); } catch(IllegalStateException e) { // OK }
52915292529352945295529652975298529953005301
// Acknowledgment handling implemenation is NOT idempotent, the channel DOES NOT allow // extraneous duplicate acknowlegments, so we test for that. try { r.acknowledge(ackm, null); } catch(IllegalStateException e) { // OK log.trace(e);
53405341534253435344534553465347534853495350
assertEquals(0, ackm.getMessageID()); Transaction tx = tr.createTransaction(); // transacted acknowledgment r.acknowledge(ackm, tx); deliveringCount = queue.getDeliveringCount(); assertEquals(1, deliveringCount); tx.commit();
53875388538953905391539253935394539553965397
assertEquals(0, ackm.getMessageID()); Transaction tx = tr.createTransaction(); // transacted acknowledgment r.acknowledge(ackm, tx); deliveringCount = queue.getDeliveringCount(); assertEquals(1, deliveringCount); tx.rollback();