1

I'm currently trying to work out what technology I can use to fire events remotely when a database changes, a realtime database of sorts. There is both an android application and a desktop JavaFx app that will communicate via the same database. When the data is changed from the desktop side, I'd like Android to update its data, and vice versa when changes occur on Android. Is there any method to achieve this without polling the DB for changes regularly?

I looked into Firebase and it seemed perfect, but lacked a desktop java library. Similarly, I have experimented with Amazon AWS Lambda and DynamoDB, and I can get a Lambda function to fire when the DynamoDB table changes. I can't however find a way for the Lambda function to update the Android/Desktop application that the data has changed though.

The JavaFx desktop application is a requirement of the project.

Apologies if this isn't possible, or if I'm overlooking a well known platform for this issue. Any help would be greatly appreciated.

Amrik Sadhra
  • 75
  • 1
  • 3

2 Answers2

1

No you not need the process of polling to achieve your results. To answer the first question, first the most flexible and plausible approach would to built a middle ware to intercept any changes.

  1. Create a script to fire events whenever the data base changes. Wether by a time interval.

Second create server, a real-time server to fire such events to any client. Third, the java fx client can use native observable for such a task. However i proposed going with a common listener, a perfect choice would be socket.io, there web-socket implementation available for android and vanilla java. For android client, whenever a data is inserted , transformed etc , use a broadcast receiver(local) to fire events in the to notify the server. Or use the socket.io connection to send events. Thats pretty much it.

Remario
  • 3,813
  • 2
  • 18
  • 25
0

Firebase + Cloud Functions for Firebase sound perfect for your use case. If the matter is pure Java support for Firebase, rather than Android, you might want to check out this question Get Firebase to work with java, not Android

Community
  • 1
  • 1
James Daniels
  • 6,883
  • 4
  • 24
  • 28