-
Notifications
You must be signed in to change notification settings - Fork 301
feat(fcm): Implement sendEach, sendEachAsync, sendEachForMulticast and sendEachForMulticastAsync (#785)
#815
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
Conversation
…st` and `sendEachForMulticastAsync` (#785) * Add org.hamcrest as dependency for unit tests * Implement sendEach, sendEachAsync, sendEachForMulticast and sendEachForMulticastAsync `sendEach` vs `sendAll` 1. `sendEach` sends one HTTP request to V1 Send endpoint for each message in the array. `sendAll` sends only one HTTP request to V1 Batch Send endpoint to send all messages in the array. 2. `sendEach` calls `messagingClient.send` to send each message and constructs a `SendResponse` with the returned `messageId`. If `messagingClient.send` throws out an exception, `sendEach` will catch the exception and also turn it into a `SendResponse` with the exception in it. `sendEach` calls `ApiFutures.allAsList().get()` to execute all `messagingClient.send` calls asynchronously and wait for all of them to complete and construct a `BatchResponse` with all `SendResponse`s. Therefore, unlike `sendAll`, `sendEach` does not always throw an error for a total failure. It can also return a `BatchResponse` with only errors in it. `sendEachForMulticast` calls `sendEach` under the hood. `sendEachAsync` is the async version of `sendEach`. `sendEachForMulticastAsync` is the async version of `sendEachForMulticast`. * Add integration tests for batch-send re-implementation: testSendEach(), testSendFiveHundredWithSendEach(), testSendEachForMulticast()
lahirumaramba
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Please get the docs reviewed if we haven't done so already in the fcm-batch-send branch.
egilmorez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few style things for you Doris! Otherwise, LGTM from a doc string perspective, thanks!
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
Outdated
Show resolved
Hide resolved
|
Kevin and Eric, thank you both for reviewing the PR! All the comments have been resolved. Merging this PR to the branch. |
|
What new method is equivalent to |
|
Hi @Doris-Ge @lahirumaramba , Could you please provide your inputs to the folllowing questions.
I appreciate your response. |
|
Add org.hamcrest as dependency for unit tests
Implement sendEach, sendEachAsync, sendEachForMulticast and sendEachForMulticastAsync
sendEachvssendAllsendEachsends one HTTP request to V1 Send endpoint for each message in the array.sendAllsends only one HTTP request to V1 Batch Send endpoint to send all messages in the array.sendEachcallsmessagingClient.sendto send each message and constructs aSendResponsewith the returnedmessageId. IfmessagingClient.sendthrows out an exception,sendEachwill catch the exception and also turn it into aSendResponsewith the exception in it.sendEachcallsApiFutures.allAsList().get()to execute allmessagingClient.sendcalls asynchronously and wait for all of them to complete and construct aBatchResponsewith allSendResponses. Therefore, unlikesendAll,sendEachdoes not always throw an error for a total failure. It can also return aBatchResponsewith only errors in it.sendEachForMulticastcallssendEachunder the hood.sendEachAsyncis the async version ofsendEach.sendEachForMulticastAsyncis the async version ofsendEachForMulticast.RELEASE NOTE:
sendAll(),sendAllAsync(),sendMulticast(), andsendMulticastAsync()APIs are now deprecated. UsesendEach(),sendEachAsync(),sendEachForMulticast(), andsendEachForMulticastAsync()APIs instead.