3940414243444546474849
set.add(3,"msg3",1,null); set.add(4,"msg4",1,null); assertEquals(4,set.size()); TransactionItem[] items = set.clear(); assertEquals(4,items.length); for(int n=0;n<items.length;n++) assertEquals(n+1,items[n].getHandle()); assertEquals(0,set.size());
5657585960616263646566
for (int i = 1; i <= 100; i++) set.add(i,"msg"+i,1,null); assertEquals(100,set.size()); TransactionItem[] items = set.clear(); assertEquals(100,items.length); for(int n=0;n<items.length;n++) assertEquals(n+1,items[n].getHandle()); assertEquals(0,set.size());
7576777879808182838485
8889909192939495969798
set.add(2,"msg2",1,null); set.add(3,"msg3",1,null); assertEquals(3,set.size()); items = set.clear(); assertEquals(3,items.length); for(int n=0;n<items.length;n++) assertEquals(n+1,items[n].getHandle()); assertEquals(0,set.size());
112113114115116117118119120121122
assertEquals(msgCount,set.size()); deliveredMessageIDs.clear(); deliveredMessageIDs.add("msg"+n); TransactionItem[] items = set.clear(deliveredMessageIDs); assertEquals(msgCount-1,set.size()); assertEquals(1, items.length); assertEquals(n, items[0].getHandle());
118119120121122123124125126
assertEquals(msgCount-1,set.size()); assertEquals(1, items.length); assertEquals(n, items[0].getHandle()); set.clear(); } } }
139140141142143144145146147148149
} public AbstractPacket receive( int maxPacketSize ) throws PacketTransportException { RawDataBuffer buffer = inChannel.ioBuffer; buffer.clear(); // Receive data int responseSize = receiveSize(inChannel.stream); if (responseSize == -1) return null;
140141142143144145146147148149150
AbstractPacket packet = (AbstractPacket)pipeline.removeFirst(); // We need to serialize the packet in a side buffer in order to // know its final size before writing it to the actual output stream RawDataBuffer buffer = outChannel.ioBuffer; buffer.clear(); PacketSerializer.serializeTo(packet, buffer); // Write it on the stream OutputStream out = outChannel.socketOutputStream; SerializationTools.writeInt(buffer.size(),out); // Packet size