final AtomicInteger sync = new AtomicInteger(138);
final AtomicInteger numResent = new AtomicInteger();
final AtomicInteger numSent = new AtomicInteger();
server.getWaitForError().acquire();
server.start();
ApnsService service =
APNS.newService().withSSLContext(clientContext())
.withGatewayDestination(LOCALHOST, server.getEffectiveGatewayPort())
.asQueued()
.withDelegate(new ApnsDelegate() {
public void messageSent(ApnsNotification message, boolean resent) {
if (!resent) {
numSent.incrementAndGet();
}
sync.getAndDecrement();
}
public void messageSendFailed(ApnsNotification message, Throwable e) {
numSent.decrementAndGet();
sync.incrementAndGet();
}
public void connectionClosed(DeliveryError e, int messageIdentifier) {
}
public void cacheLengthExceeded(int newCacheLength) {
}
public void notificationsResent(int resendCount) {
numResent.set(resendCount);
sync.getAndAdd(resendCount);
}
})
.build();
server.stopAt(eMsg3.length() * 50 + msg1.length() * 3
+ eMsg2.length() * 2 + eMsg1.length() * 85);
for (int i = 0; i < 50; ++i) {
service.push(eMsg3);
}
service.push(msg1);
service.push(eMsg2);
service.push(eMsg1);
service.push(msg2);
for (int i = 0; i < 85; ++i) {
service.push(eMsg1);
}
server.sendError(8, eMsg2.getIdentifier());
server.getWaitForError().release();
server.getMessages().acquire();