I have an app written with JSF and Spring using JPA+Hibernate which is running on a Glassfish4 server.
Right now I have an Observer pattern which is listening for some Postgresql events. Let`s say that on very insert in some table my listener is triggered.
Everything is OK now because I have only one server but I want to migrate to a cluster (4 nodes) setup, so there will be a problem because when an row will be inserted my trigger will be fired 4 times.
What is the common approach when you have to deal with this kind of things ?
I was thinking to keep a database table and when an event appears to check if the event id is not already in the table, but I think here I will have some concurrency issues and I`ll have some rolled back transactions.
Any idea how I can elegantly deal with this ?