Messages system to users

  • HI ALL

    I am building a messages system that works between the users of the application. I want the users to get the messages seconds after the send time. I have planed it like this:

    1.VB open a with events connection object and executes "spAlertOnMessage"

    2.spAlertOnMessage stored procedure gets @IDENT_CURRENT('MSG TABLE') and loops until the identify key changes

    3.raise an error, which is recognized by vb

    4.spAlertOnMessage continue the loop

    And my questions are…

    1.Is there a better way to this messages system?

    2.Is there a way to make the after insert trigger, to set a global variable that data was added and then make "spAlertOnMessage" check its value?

    3.Is there a way to make the after insert trigger or other routine to inform all clients that a message was added, without opening 100 connections (1 for each client)?

    Any ideas?

    Thanks!!!


    Thanks!!!

  • MS have notification services planned for SQL server on dot net framework solution but its still in beta I think. Might be worth a look.

    http://www.microsoft.com/sql/NS/overview.asp

    I implemented a messaging system (not in VB)with similar results to yours using a timer on the client app inherited to every form (ie only coded once) that does a trivial select every xseconds for messages for that user based on datetime comparisons (using server datetime). Its simple and it works, although the purists would probably not like it !

  • I'd just let the app check every xx seconds. It's going to do this in the background anyway with your solution. I'd also just check a table for a new record, not worry about triggers or anything else.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • Notification services might be overkill from what I saw of it. It's a sound idea, one place for all alerts & messages to originate from, just not simple to implement. I agree with steve that a timer on a form is probably good enough in this case. Have an app that does that myself, though I think we only check at a certain phase in the app, a few minutes delay is not critical to us.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • wow it is the first forum i've been answered so quickly and by so many...its a great forum! and 10x all of u...

    I've choosed to implement it that way coz I think it whould save a lot of network traffic, coz the checking every 5 seconds r all done in the server side, with only 1 execution, while doing it ur way the every app client executes aa query every 5 seconds.

    why am I wrong?

    Thanks!!!


    Thanks!!!

  • The overhead for checks is small. Plus it's then distributed. I see a constant connection as a failure point, especially since if you do not check the link constantly, it could drop and you could miss messages.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply