[erlang-questions] Mnesia system events and table events
Alexander Lamb
alexander.lamb@REDACTED
Sun Oct 7 21:39:01 CEST 2007
Hello,
I am trying to understand some Mnesia concepts and am wondering about
the capabilities of notifying of changes.
Indeed, in a traditional application using a database such as MySQL
for example, if I want to make sure I always have the last version of
some data, I need to either:
A) never cache any data in memory and refetch data at each query
B) use a memory cache (we use Cayenne with Java) and make sure all
reads and writes are always going through the same process / cache
In some situations this is not acceptable.
Therefore, in the situation were I implement some services using a
database, I want to make sure that when the database changes, all
processes (Erlang or others) get notified of a change.
To achieve this I thought it would be possible to implement the
business logic in Erlang using Mnesia as a back-end database. Then,
have one Erlang process listening to all changes to the tables and
for each change, send a message, for example on a message bus such as
RabbitMQ. Then, clients in other languages than Erlang could listen
to changes and update an object graph accordingly.
Is this the way to go? In details:
1) is using table events in Mnesia a usual way to notify other
processes of changes?
2) I suppose the events are sent aynchronously... what about
performance issues?
3) If I have a multi-node Mnesia database, I suppose I will only
receive one event per event (not one per node)?
4) If this is the way to go, would you send on the bus:
a) the Name and Key of the record(s) which changed (leaving the
listening, non Erlang process to refetch immediately after what it
needs)
b) the complete record(s), event the attributes which didn't change
c) only the changed attributes
I was thinking of converting the events in JSON messages which could
be listened to from any non Erlang process. Actually, this seems
rather generic so maybe someone already had a thought about that kind
of architecture.
In practice, we are considering rewriting a module of our system.
By putting in place some standardized way of communicating between
Applications we can develop the new system incrementally.
Thanks for any hints!
Alex
--
Alexander Lamb
Founding Associate
RODANOTECH Sàrl
4 ch. de la Tour de Champel
1206 Geneva
Switzerland
Tel: 022 347 77 37
Fax: 022 347 77 38
http://www.rodanotech.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071007/0812f6b9/attachment.htm>
More information about the erlang-questions
mailing list