Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

跪求作者答疑 #13

Open
qysnowqy opened this issue Feb 10, 2015 · 4 comments
Open

跪求作者答疑 #13

qysnowqy opened this issue Feb 10, 2015 · 4 comments

Comments

@qysnowqy
Copy link

 作者,您好,我基于您的apns4j,写了一个ios推送应用。
 主程序不断读取queue中的数据。有数据推,否则休息。
 遇到了一些情况。希望您赐教
 1.ApnsConnectionImpl中推一条输出日志,再推不输出日志
 2.输出日志的时候,测试机器都收到,不输出日志的时候个别测试机收到

  以下是我的代码
            IApnsService service = getApnsService();
    new Thread(new DelFailTokenThread(service)).start();
    int sleep = 0;
    int timeSleepCount = 0;
    while (true) {
        try {
            payment = (QueuePushPayment) memcachedClient.get(queue);
            if (payment == null) {
                if (sleep < sleepCount) sleep++;
                logger.info("push thread is   sleepCount=" + sleep);
                if(sleep == sleepCount){
                    sleep = 0;
                    try {
                        Thread.sleep(60000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }else{
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            } else {
                timeSleepCount++;
                if (sleep > 0)  sleep--;
                Payload payload = getPayload(payment.getPayload());
                service.sendNotification(payment.getDeviceToken(), payload);
                payload = null;
                if (timeSleepCount  == 10000) {
                    timeSleepCount = 1;
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
@RamosLi
Copy link
Owner

RamosLi commented Feb 11, 2015

通过现在的信息很难去判断到底问题出在哪儿
建议你在sendNotification之前打一条log,然后再跟ApnsConnectionImpl中输出的log一一比对下,看是否能对应的上。

如果用log4j的话,可以这么配下




@qysnowqy
Copy link
Author

感谢您的答复。请问您的每天百万推送一般设置线程池大小为多少?

@RamosLi
Copy link
Owner

RamosLi commented Feb 11, 2015

为了避免单点,我在两台机器上搭了APNS的推送服务,poolSize设的是12,每台机器每天各自发送100多万条通知,CPU和内存消耗都特别低。

@qysnowqy
Copy link
Author

再次感谢。那个log不输出的问题我定位了。
dev-3 Received error response. status: 8, id: 180, error-desc: Invalid token
有这个info输出的时候,下次推送就不会出现info日志了。
请问这个token是失效的吗?如果是失效的,feedbackservice没有返回。
这个应该是错误token吧?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants