Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Jan 2012
    Location
    seri petaling
    Posts
    2

    Data persistency

    I am building an application base on chat adapter and I have one question appreciate if anybody can help me out.

    Basically the demo application does not persist the data once the last person quit from the browser. Is there an easy way to persist the data so that the next time someone subscribe to my item, the older messages are still there?

    Regards,
    YS

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    975
    In fact, Lightstreamer Server, after issuing a subscribe() request to the Data Adapter, takes care of keeping the item snapshot updated;
    but as soon as clients are no longer interested, it issues a unsubscribe() request and quits keeping the item snapshot.
    When eventually a new client connects, the Server will issue subscribe() again.
    At this point, the Data Adapter will have the opportunity to send the current item snapshot to the Server.
    So, if the Data Adapter also keeps the snapshot up-to-date on the items it manages, it can fill the gap.

    Otherwise, the only option is to cheat the Server by adding a fake client which subscribes to the needed items and never quits.
    This fake client can (and should) be run on the back-end side, but there is no special channel available to communicate with the Server:
    it has to communicate in the same way as the other clients do, that is, by issuing request through the Server listening ports.
    If you are using the Moderato edition, so that only the JavaScript Client Library is available, you could, for instance, write this fake client in NodeJS.

  3. #3
    Member
    Join Date
    Jan 2012
    Location
    seri petaling
    Posts
    2
    Quote Originally Posted by DarioCrivelli View Post
    In fact, Lightstreamer Server, after issuing a subscribe() request to the Data Adapter, takes care of keeping the item snapshot updated;
    but as soon as clients are no longer interested, it issues a unsubscribe() request and quits keeping the item snapshot.
    When eventually a new client connects, the Server will issue subscribe() again.
    At this point, the Data Adapter will have the opportunity to send the current item snapshot to the Server.
    So, if the Data Adapter also keeps the snapshot up-to-date on the items it manages, it can fill the gap.

    Otherwise, the only option is to cheat the Server by adding a fake client which subscribes to the needed items and never quits.
    This fake client can (and should) be run on the back-end side, but there is no special channel available to communicate with the Server:
    it has to communicate in the same way as the other clients do, that is, by issuing request through the Server listening ports.
    If you are using the Moderato edition, so that only the JavaScript Client Library is available, you could, for instance, write this fake client in NodeJS.
    Thanks Dario for your suggestion of adding a fake client. I will try that if everything else fail.
    Actually my program is a modification whereby the adapter will get initial data from the database. I have managed to pump the data to adapter.
    But how can I make the server keep the snapshot even before anyone is subscribed?
    Currently the behavior is, if no one is subscribed, it will not store it. And also, once no one is subscribed, it also discarded it.
    What is the proper way to make it work as I would want it to?

  4. #4
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    975
    The problem of keeping the snapshot "even before anyone is subscribed" is quite the same as keeping it "once the last person quit from the browser", so the answer is also quite the same.
    By resuming:

    Using a fake client and having the Data Adapter start it upon init() would work. Note that the Data Adapter must know what items have to be handled in this way.

    The canonical way to do the same should be for the Data Adapter to be able to acquire the item snapshot in some way, so as to forward it to the Server upon each invocation of subscribe().
    If the feed does not provide snapshot information, then the Data Adapter should keep and update the snapshot internally;
    this could be initiated immediately, upon init(), provided that the Data Adapter knows what items have to be handled in this way.

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 02:12 AM.