Search code examples
javadatabasepush-notificationreal-time

Notification for each transaction in a database


I am trying to build a push notification system.My requirement is whenever a DB entry is updated i need a push notification should send to the customer.

I have implemented the same using the Google FireBase.I need to have it in local for getting the full control.is there any real time database available as opensource for implementing the same?

Or is there any alternate way to implement the same?


Solution

  • I suggest using Spring integration. You can use a @Router channel when persisting to DB. the @Router channel will forward your routing request to the DB and to another channel for notifying the customer.

    @Router(inputChannel="persistingAndNotifyingCustomerChannel")
    public String[] route(Object payload) {
       return Arrays.AsList("persistingChannel", "notifyingCutomerChannel");
    }
    
    @ServiceActivator(inputChannel = "persistingChannel")
    public void persist(Object payload) {
        // persist
    }
    
    @ServiceActivator(inputChannel = "notifyingCutomerChannel")
    public void notify(Object payload) {
        // notify
    }