How to implement a messaging system?
Amir Ansari
fractallyte at csi.com
Tue Jan 4 14:14:36 UTC 2011
OK, I made the system far more complex than necessary; your comments about the suitability of MagmaCollection made everything clear. It'll work fine now.
Actually, I started this simply enough, in exactly the way you suggested, but using OrderedCollection - and when it didn't work properly I complicated everything instead of simply using a MagmaCollection.
Thanks for your help Chris!
And, of course, thanks for your comments Facu.
Amir
On Mon, 3 Jan 2011 12:33:11 -0600
Chris Muller <asqueaker at gmail.com> wrote:
> > I originally thought to create a mailbox for each user in a MagmaPreallocatedDictionary, with the association User -> OrderedCollection (where 'User' is an instance of class 'User', so each item would be unique).
>
> Why are you wanting to use a MagmaPreallocatedDictionary to hold
> Users? How many users are in the system and how fast do they need
> access to their list of new messages?
>
> When I pull up my mail client, it takes a couple of seconds for my
> Inbox to be displayed. This is analagous to using a MagmaCollection
> for each user's message.
>
> Recall what I said MagmaCollections were designed for: For end-user
> query requirements, which is exactly the case you've stated: A user
> comes to check on their messages. So a MagmaCollection is perfectly
> appropriate for that, not a MagmaPreallocatedDictionary.
>
> I don't know how many users you will have, but given the extremely
> simple access requirements, you could put htem into a MagmaCollection
> as well.
>
> So, you have one MC for "AllUsers" and then one MC for each user
> containing that users messages.
>
> > So, checking up on one's own mailbox would simply entail finding oneself's User in the Dictionary and reading the associated collection of messages.
> >
> > However, if another user were to drop a message into this collection, the same OrderedCollection would have to be accessed by another session. Isn't this a no-no, even with refreshing a session?
>
> I'm wondering what you mean by "the same OrderedCollection". The same
> one in the database? Or the same one in image memory?
>
> Yes, it will be the same one in the database, but it will be different
> ones in image memory if they are retrieved by different sessions.
>
> >
> > Are you suggesting to use MagmaCollections instead of OrderedCollections? Isn't that far more 'expensive', especially since each user on the system would be assigned such a collection just to hold their messages?
>
> MagmaCollections consume more resources than a OrderedCollection, yes,
> but the reason I stated was that it would allow multiple messages to
> come into the same user and avoid a commit-conflict.
>
> - Chris
More information about the Magma
mailing list