update
This commit is contained in:
@@ -13,12 +13,15 @@ import org.springframework.util.StringUtils;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static com.notnoop.apns.DeliveryError.INVALID_TOKEN;
|
||||
|
||||
@Component
|
||||
public class ApnsServer implements ApnsDelegate {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ApnsServer.class);
|
||||
private static ExecutorService mExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 5);
|
||||
@Override
|
||||
public void messageSent(ApnsNotification message, boolean resent) {
|
||||
LOG.info("APNS push sent:{}", message.getDeviceToken());
|
||||
@@ -100,7 +103,13 @@ public class ApnsServer implements ApnsDelegate {
|
||||
|
||||
|
||||
public void pushMessage(PushMessage pushMessage) {
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
mExecutor.submit(()-> {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now - start > 5000) {
|
||||
LOG.error("等待太久,消息抛弃");
|
||||
return;
|
||||
}
|
||||
ApnsService service = developSvc;
|
||||
if (pushMessage.getPushType() == IOSPushType.IOS_PUSH_TYPE_DISTRIBUTION) {
|
||||
if (pushMessage.pushMessageType == PushMessageType.PUSH_MESSAGE_TYPE_NORMAL || StringUtils.isEmpty(pushMessage.getVoipDeviceToken())) {
|
||||
@@ -183,5 +192,7 @@ public class ApnsServer implements ApnsDelegate {
|
||||
for (final Map.Entry<String, Date> ent : inactiveDevices.entrySet()) {
|
||||
LOG.info("Inactive " + ent.getKey() + " at date " + ent.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user