Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a Queue on Database rows?

Right now I am trying to create a process, where I want to insert data in table and some observers will get notified and able to edit the data upon their interest. Below is a rough idea on how to do it. Can anyone please suggest the model/arch how I can achieve this?

enter image description here

like image 338
Nama Avatar asked Apr 29 '19 08:04

Nama


People also ask

What is a database queue?

A queuing system is composed of producers and consumers. A producer enqueues messages (writes messages to a database) and a consumer dequeues messages (reads messages from the database).

How do I create a queue in SQL Server?

ON filegroup | [DEFAULT] Specifies the SQL Server filegroup on which to create this queue. You can use the filegroup parameter to identify a filegroup, or use the DEFAULT identifier to use the default filegroup for the service broker database.


1 Answers

Follow this tutorial on Room, ViewModel, and LiveData.

Room is a SQL database abstraction which can expose its data through LiveData. ViewModel is a class that holds data for the UI and survives configuration changes. LiveData is an observable container for data that is aware of the android lifecycle so you don't have to manage it in the lifecycle callbacks.

Basically, you create a Room database then expose LiveData objects to the ViewModel. The ViewModel in turn exposes LiveData objects to the fragment/activity. The fragment or activity observes the ViewModel's LiveData by attaching an Observer. The Observer defines how the fragment/activity reacts to changes in the data.

If you prefer RXJava you can follow this tutorial instead. It's essentially the same, but instead of exposing data with LiveData you use reactive streams.

Edit: here's a really good article on architecture: https://proandroiddev.com/android-architecture-starring-kotlin-coroutines-jetpack-mvvm-room-paging-retrofit-and-dagger-7749b2bae5f7

like image 141
AaronJ Avatar answered Oct 19 '22 16:10

AaronJ