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

add sent callback #171

Closed
qifuren1985 opened this issue May 19, 2015 · 6 comments
Closed

add sent callback #171

qifuren1985 opened this issue May 19, 2015 · 6 comments

Comments

@qifuren1985
Copy link

when a notification sent, we need do some thing. so maybe we need add sent callback support.

@jchambers
Copy link
Owner

Sadly, this just isn't something we can do reliably. Please see #130 (and also the FAQ) for additional discussion.

To recap, the APNs protocol itself never acknowledges successful notifications, so we have no way of telling the difference between a successfully-sent notification, a notification that disappeared into space, or a notification that failed and just hasn't been rejected yet. We wouldn't want to tell listeners that a notification has been sent, but then report the opposite a few milliseconds later if the notification ultimately gets rejected.

@qifuren1985
Copy link
Author

sent means write to netty buffer success.

@jchambers
Copy link
Owner

Could you please elaborate on the use case you have in mind? I'm still struggling to think of a scenario where knowing about individual writes without knowing about their outcomes would be helpful. That's not to say such a scenario doesn't exist—I just haven't thought of it yet.

@jchambers
Copy link
Owner

@qifuren1985 Do you intend to use this kind of thing strictly for health/performance monitoring? If so, please let me call your attention to #175. If not, please do let us know so we can make sure we're considering your use case!

@qifuren1985
Copy link
Author

use case: Push message is stored in Redis, when the message has writen to Netty, I need to remove the message from Redis, so I need a callback to do this thing.

The reason save message in Redis: If I have 10,000,000 message to push, message add to queue may be only 1 second, but write to Netty need much more time, If program crash when writing to Netty, I will don't know which message has sent. The next time when program resume, I need to resend these failed push.

@jchambers
Copy link
Owner

If you're trying to control the rate at which notifications are taken from an external source, you might try providing a custom BlockingQueue to the PushManager constructor. In particular, a SynchronousQueue might do exactly what you need. You can only add one thing at a time to a SynchronousQueue, and Pushy won't take things from the queue until it's ready to send them. Using a SynchronousQueue means that you'll block on adding to the queue until at least a first attempt has been made to send the notification.

Please note, though, that this won't totally solve your problem (and this is a limitation of the APNs protocol). Because notifications can be rejected after an unknown delay, you could still theoretically "send" thousands of notifications before finding out that an earlier notification was rejected, and all of the subsequent ones need to be resent. Pushy will take care of all of that for you behind the scenes, but I do want to be clear that it's very hard to know when a notification is truly sent.

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

No branches or pull requests

2 participants