Replacing a polling event source when upgrading MobileFirst JavaScript adapter from 7.1 to 8.0 - ibm-mobilefirst

In our existing MFP 7.1 project, we're relying on the polling event source in a JavaScript adapter to create a scheduler which enables an interval-specific operation such as watching over a database table for new records to process at server side. The implementation was based on the following guide:
http://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/devref/t_configuring_a_polling_event_source.html
However, we discovered that polling event source is nowhere to be found in the MFP 8.0 documentation and the following document states that polling event source is no longer supported:
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/product-overview/release-notes/deprecated-discontinued/
We would like to know what is the recommended approach to migrate from 7.1 to 8.0 when dealing with polling event source such as this, and what is the alternative way suggested if there is no possible way in MFP 8.0. Thanks.

Polling is indeed not supported in MobileFirst Foundation 8.0.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/upgrading/migrating-push-notifications/
I don't have any official alternative, but since polling is the checking of some backend for new content and if true, then have a notification dispatched, you can still create some service of your own to check your backend if there is a new "record" or new otherwise new content, and if true, the construct a JSON for that notification and send it.
In v8.0 you have multiple REST endpoints you could use together with Confidential clients to send it.
http://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/rest_runtime/c_restapi_runtime.html
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/confidential-clients/
You can also take a look at the following way of constructing a mechanism to send notifications using Node.js: https://mobilefirstplatform.ibmcloud.com/blog/2016/10/18/using-mff-8-push-service-rest-api-in-a-nodejs-based-server/

Related

How to keep streaming if initial client loses connection?

I'm working on an app that streams out multiple presenters via the Agora Live Streaming protocol. Everything works great so long as the person who started the live stream stays connected, however if they lose internet, the stream stops, even if other presenters are still online.
Is there a way to tell the live stream to keep going until "stop live streaming" is called (or all presenters are offline)? My code can handle updating the transcoding config (e.g. video layout) when they go offline.
After multiple discussions with Agora Support, it appears the answer is no, if only using the web SDK, however they are introducing a new server side feature to make this possible.
It's currently in beta, so you'll have to ask Agora Support to enable it for your account, but once you've done so you can create and update an RTMP converter via their server side API instead of relying on the client SDK to manage the stream: https://docs-preprod.agora.io/en/Interactive%20Broadcast/streaming_restful
I'm assuming you're using startLiveStreaming method using the Agora Web SDK. You can attach event listeners on all hosts to listen for primary host's online status, in case the primary host (the host that calls the start method) goes offline - a secondary host can call the start (and transcode) method.
You can also use Agora RTM to signal this status.

Mobilefirst 8.0 and scheduled tasks (similar to Quartz)

I'm using MobileFirst 8.0 in my project and I'd like to add some interesting use cases... Anybody knows if there are any options to schedule tasks in MobileFirst?
I have experience with Quartz library. Is there something similar to it? Or something that the MobileFirst server provides for this purpose?
Thanks in advance and best regards
Custom tasks cannot be scheduled in MobileFirst 8.0.
You can, however, have schedulers or jobs running outside of MFP, that invokes MFP REST endpoints to execute some task/job periodically.
List of MFP REST endpoints:
REST API for the MobileFirst Server administration service
REST API for the MobileFirst Server push service
REST API for the MobileFirst runtime

Worklight:Can we use two-phase commit in Java code which called from JS adapter?

According to below, we can call Java code from javascript adapter.
Calling Java code from a JavaScript adapter
http://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSZH4A_6.2.0/com.ibm.worklight.dev.doc/devref/t_calling_java_code_from_a_javas.html
We plan to install worklight server on WAS full profile. WAS full profile supports two-phase commit.
Transaction support in WebSphere Application Server< br/>
http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/cjta_trans.html?cp=SSAW57_8.5.5%2F3-2-7-3&lang=en
To call java code from adapter, we need to deploy it on "Worklight server". Can we use two-phase commit in java code? Are there any limitations when using java code on worklight server?
Thanks in advance!
The only limitation I am aware of is that the WAS security context is not propagated to Worklight adapter's thread. But generally speaking, the same capabilities exist and the same servlet API is available.
You can read more about Java Vs JavaScript in adapters, in this question: Worklight Adapters - Java vs JavaScript
That said, two-phase commit was never tested in practice, so it may work and may not work... for the same reason as the security context mentioned above. As a transaction is usually associated with a thread, and that thread is not available for Worklight adapters which are using their own thread pool.
This limitation mentioned above may be removed in a future release of Worklight, which in turn may make it possible to use the two-phase commit feature.

IBM Worklight Offline Support

we have an app which uses JSONStore to support offline, if device is offline and user submit data it stores it offline, now when device is online and when user login to the app it sync with server and submit all data to server.
the question is, Is it possible when device comes online then my offline data sync with server without user open my app ?
Does worklight support that? Or I have to do something else?
please advice
Like Idan said, Worklight does not support this, but depending on the OS, it could support it.
For instance, on Android, you could use BroadcastReceivers to detect changes in network connectivity, and execute an action when it happens, regardless of whether your app is closed or not.
Here is the API for the receiver: http://developer.android.com/reference/android/content/BroadcastReceiver.html and here is a SO answer explaining how to use it to detect WiFi connectivity: https://stackoverflow.com/a/22626736/2245921 So you can modify this BroadcastReceiver to run the sync code that you would normally do if your app was already open.
If you are using any other platform (iOS, Windows) there might be an equivalent that you can use.
Also, keep in mind that if you are doing a hybrid application, you can create your own Cordova plugin to execute native code from Javascript. Here is the documentation on how to do so: http://cordova.apache.org/docs/en/3.5.0/guide_hybrid_plugins_index.md.html#Plugin%20Development%20Guide

How can i create local Notification in worklight

I'm creating an app using Worklight. I need to show a Notification at specific time like an alarm clock. It'd work when offline so i cannot use Push Notification.
I need Notification like image below. Thanks.
iOS's Local Notifications feature does not have built-in support in Worklight.
One way to add Local Notifications support is by extending your application using a Cordova plug-in, which will allow you to run Native code.
This means that you will natively implement it by following Apple's APIs: to schedule the notification in the app and to then receive a notification locally via the OS, that will in turn allow you to open the app and execute an optional callback, etc...
You could either write a custom Cordova plug-in of your own,
Or find existing plug-ins on the web.
When adding an existing Cordova plug-in to Worklight (depending on your version of Worklight and version of Cordova), the instructions to do so are a bit different at this time.
This video demonstrates one instance of how to do add an existing Cordova plug-in: Integrating Cordova plugins into Worklight applications