Proposal a): use of JMS messaging
I believe most correct solution would be incorporating messaging here:
Each REST call ( push message ) would produce many push notification messages - one message (JMS) for each installation that should be notified.
Each push notification would be then send in own transaction (which would also satisfy persistence of the message for fail-over purposes).
In push notification transaction: - the notification sending would either succeed (confirmed by push network) - rejected by push network (rejected with given outcome - e.g. invalid endpoint/installation) -> acted upon specifically based on outcome - fail/timeout -> marked for redelivery
(use of CompletionListener#onCompletion / #onException handling)
At the end, onCompletion/onException listener would increment counter of delivered messages - the correct solution is up to discussion here, but I can see Infinispan (at least its ruby-client) is able to count messages atomically (https://github.com/infinispan/ruby-client/issues/1).
----
There may be other solutions like batches with database transactions, but I believe this is conceptually most clear.
|