通过 JavaPNS 发送推送通知时,发生异常并显示以下消息。
Exception in thread "JavaPNS grouped notification thread in LIST mode" java.lang.OutOfMemoryError: Java heap space
我猜原因是因为我尝试向太多用户发送通知1次。
public void send (List<Device> devices, Object keystore, String password, boolean production) {
/* Prepare a simple payload to push */
PushNotificationPayload payload = PushNotificationPayload.alert("Hello World!");
/* Decide how many threads you want to create and use */
int threads = 30;
/* Start threads, wait for them, and get a list of all pushed notifications */
List<PushedNotification> notifications = Push.payload(payload, keystore, password, production, threads, devices);
}
我将 73,889 个设备 token 添加到列表devices
中并收到了异常。
您认为我需要多次发送通知吗? 有人知道向很多人发送通知吗?
谢谢!
最佳答案
我可以想出 2 个解决方案来解决您的问题:
1) 批量发送...比如 20k
或
2)增加堆内存大小
示例: java -Xms512m -Xmx512m
(进行搜索...)
关于java - 通过 JavaPNS 发送通知时发生异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11049207/