Home Help Center

Notification service

Hello,

In my little testcase there are several clients connecting to a database through a server. If a client reads an object from the database he creates a local instance of it and holds the data on client-side.
Now one client makes changes to an object. Other clients, which hold the same object shall be informed about the changes.

Is there any possibility to inform the other clients about the changes? Maybe IceStorm is the solution of my problem?

Thanks.

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    In essence, what you describe is a distributed version of the observer pattern: Several clients observe one object, and must be notified if this object changes.

    The simplest solution is indeed to use IceStorm. You can either push the changes directly to the clients using IceStorm (efficient), or you can just notify the clients of any changes with IceStorm and then have them update their local copy (simple).

    It is also possible to implement such a distributed observer pattern yourself, but of course this is a lot more work. You would have to write subscribe and unsubscribe methods, make sure that clients that go link-dead are dumped, etc. It's simpler to use IceStorm.
  • I've just looked at the clock demo and there are some questions how I shall implement IceStorm in my testcase.

    1.) Do I have to create an additional Slice definition to implement IceStorm?
    2.) Is it necessary to create Publisher- and Subscriber-files or is it enough to implement the extra code into my server and clients?
    3.) In the clock-demo the message direction is from client to server (correct me, if I go wrong), in my case I need it vice versa. Is it possible to change the client side with ther server side?

    Thanks.
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hello,
    1.) Do I have to create an additional Slice definition to implement IceStorm?

    IceStorm is "a typed event" service. You need to define the interface through which your clients are going to get these update notifications. The clock demo uses the Clock interface to send ticks.
    2.) Is it necessary to create Publisher- and Subscriber-files or is it enough to implement the extra code into my server and clients?

    You should add this code to your clients (subscribers) and server (publisher).
    3.) In the clock-demo the message direction is from client to server (correct me, if I go wrong), in my case I need it vice versa. Is it possible to change the client side with ther server side?

    In this case you server will be both a server and a publisher (a form of client), and your client will be both a client and a subscriber (a form of server). This is very common.

    Cheers,
    Bernard
  • Mr.FreezeMr.Freeze Member
    Hello,

    I try to update my clients directly after an object was changed. That means one client changes an object and other clients that hold the same object should get the updated proxy. Therefore I made the following Slice - Definition:

    MyType* notify(MyType* myObject);

    The function takes an updated proxy as parameter. The return value is also a proxy.

    At runtime I get the following error message on server side.

    server: warning: dispatch exception: Basicstream.cpp: 464: Ice::UnmarshalOutOfBoundsException: protocol error: out of bounds during unmarshaling
    identity: myObject
    facet:
    operation: notify

    So it seems to me that I forgot to implement something on client side, that takes the proxy over.

    So, now I don't know how I can push the changes to my clients? Maybe my Slice - Definition is not the best solution, and if so is there another way to do this?
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    I believe you are trying to invoke this method as oneway. (If you use IceStorm, it must be oneway.) However, oneway methods cannot have any return values. The error message you get is not very descriptive. We fixed this for the upcoming Ice 1.2, then you will get a "oneway only" exception.
  • Mr.FreezeMr.Freeze Member
    Hello,

    yes, I use IceStorm.

    If it is not possible to return a proxy to the clients, how can I push the changes directly to them?

    Thanks in advance.
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    I don't understand. If you want to push changes, what do you need a return value for?

    IceStorm is one-to-many communications, so there can be no return value.
  • Mr.FreezeMr.Freeze Member
    O.K., my idea is the following.

    The clients should get a message that their object is updated. The problem is the changes should not be made immediately. The client should get the new data, but he shall decide himself, when he updates his object.

    If this isn't possible, I think I will push the changes directly to the clients.
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    From a technical point of view, your client must be a server, i.e., it receives requests, and implements a method with which IceStorm can push events to the "client".

    Also from a technical point of view, the server (i.e., the event emitter) is a client, in that it sends requests to IceStorm for distribution to the event receivers.

    When the event receiver gets an event from IceStorm, it can decide what to do with it, throw it away, keep it for a while, or updates its state immediately. This is completely up to the application developer.

    I suggest to have a look at demo/IceStorm/clock for an example. To run this demo, see demo/IceStorm/clock/README.
  • Mr.FreezeMr.Freeze Member
    O.K., now I know what you mean.

    Because of these are my first steps in distributed programming some things are hard for me to understand.

    Thanks for your patience.
Sign In or Register to comment.