Scheduling the Push Notification Task
When many devices communicate with the server at the same time, the server crashes. To avoid this situation WSO2 IoT Server implemented a task to manage the number of devices communicating with the server at a given time. The task sends the notifications to the devices in batches. This way at a given time only a defined number of devices will communicate with the server.
Open the
<IOTS_HOME>/conf/cdm-config.xml
file and make sure theSchedulerTaskEnabled
that is underPushNotificationConfiguration
is enabled. This configuration is enabled by default.In a clustered environment make sure to enable this task only in the manager node and not the worker nodes. Else, the server crashes when the worker nodes start pushing notifications along with the manager node.
<PushNotificationConfiguration> <SchedulerBatchSize>1000</SchedulerBatchSize> <SchedulerBatchDelayMills>60000</SchedulerBatchDelayMills> <SchedulerTaskInitialDelay>60000</SchedulerTaskInitialDelay> <SchedulerTaskEnabled>true</SchedulerTaskEnabled> <PushNotificationProviders> <Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider</Provider> <!--<Provider>org.wso2.carbon.device.mgt.mobile.impl.ios.apns.APNSBasedPushNotificationProvider</Provider>--> <Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider</Provider> <Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider</Provider> </PushNotificationProviders> </PushNotificationConfiguration>
SchedulerBatchSize
Define how many devices or the device batch size a notification needs to be sent at a given time.
By default, a notification is sent to 200 devices at a given time. If you have less than 200 devices registered with WSO2 IoT Server, the notification will be sent to all those devices.SchedulerBatchDelayMills
Define after how many milliseconds the notifications needs to be sent to the next batch of devices.
By default, the next batch of devices will get the notification after 60,000 milliseconds, which is in a minute.SchedulerTaskInitialDelay
The server will not send notifications to the devices soon as it starts. Therefore, define when the push notification schedule task needs to start. The value needs to be defined in milliseconds.
By default, the task starts 60,000 milliseconds or one minute after the server starts.SchedulerTaskEnabled
Enable the push notification scheduler task. If it is is not enabled, WSO2 IoT Server will send the push notifications to all the registered devices in one go. This might result in the server crashing as explained above. PushNotificationProviders
The default push notifications that are supported and implemented in WSO2 IoT Server. Configure the device type to run the push notification scheduler task.
Navigate to the<IOTS_HOME>/repository/deployment/server/devicetype
directory, open the<DEVICE_TYPE>.xml
file, and configure the field given below:
The default configuration in theandroid.xml
file is shown below:<PushNotificationProvider type="FCM" isScheduled="false">--> <!--</PushNotificationProvider>
The task for the FCM push notification method is disabled for the Android device type by default. Therefore, all the Android devices registered with WSO2 IoT Server will receive the push notifications at once and the devices will communicate with the server at the same time. If you want to change this default behavior, enable the scheduler task for the device type.
<PushNotificationProvider type="FCM" isScheduled="true">--> <!--</PushNotificationProvider>
NOTE: In WSO2 IoT Server, the Android devices are configured to send notifications via the local polling notification method by default.