You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using laravel 5.2.
I have nearly 15k users in my db. I used to send notification to each user based on their registered token. 1000 user at a time along with their token and the message It was taking so long.
Now I am trying to create a common topic for now, and I will subscribe every user to this topic.
I created a simple script to subscribe them all. I know I can't subscribe more than 1000 users at a time.
It's obvious there is many reasons that a user has not been subscribed. for example . The token has expired.
Here is the code to subscribe all the users.
//Start subscribing all user to a common topic
//collect all users tokens
$results = User::select( 'regId')
->get()->toArray();
$user_tokens = array();
foreach($results as $result) {
array_push($user_tokens, $result['regId']);
}
//subscribe all users in batches
$batch_size = 1000; // 1000 per request
$iterations = ceil(count($user_tokens) / $batch_size); // determine how many iterations are needed
for ($i = 0; $i < $iterations; $i++) {
$offset = $i * $batch_size;
$batch_of_1000_user_ids = array_slice($user_tokens, $offset, $batch_size);
$messaging->subscribeToTopic('test', $batch_of_1000_user_ids);
}
//End sbuscribing all users to a common topic
So I want to know. How can I know if a user is successfully subscribed?
Does this method $messaging->subscribeToTopic('test', $batch_of_1000_user_ids); generate any error if a user hasn't been subscribed.
Also, does this process stops if a user hasn't been subscribed succsessfuly? for example - suppose first nth user are subscribed, and there is an error on n+1rst user in that case what will happen . Will this method skip that user and continue subscribing rest users.
It will be easier for me to track how many users has not been subscribed.
I found some reference on the docs on Validate messages Section , but I am not sure if this will work in this case.
If the request goes through (= no exception has been thrown) you can expect the subscription to be successful.
As for the error cases, unfortunately, I cannot be sure at the moment what happens when one of the tokens "in the middle" of a request fails, so I can't tell you with certainty if the rest still is subscribed, or if the whole process fails.
I am using laravel 5.2.
I have nearly 15k users in my db. I used to send notification to each user based on their registered token. 1000 user at a time along with their token and the message It was taking so long.
Now I am trying to create a common topic for now, and I will subscribe every user to this topic.
I created a simple script to subscribe them all. I know I can't subscribe more than 1000 users at a time.
It's obvious there is many reasons that a user has not been subscribed. for example .
The token has expired.
Here is the code to subscribe all the users.
So I want to know.
How can I know if a user is successfully subscribed?
Does this method
$messaging->subscribeToTopic('test', $batch_of_1000_user_ids);
generate any error if a user hasn't been subscribed.Also, does this process stops if a user hasn't been subscribed succsessfuly?
for example - suppose first nth user are subscribed, and there is an error on n+1rst user in that case what will happen . Will this method skip that user and continue subscribing rest users.
It will be easier for me to track how many users has not been subscribed.
I found some reference on the docs on Validate messages Section , but I am not sure if this will work in this case.
The text was updated successfully, but these errors were encountered: