Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Member
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    9

    Table.onEndOfSnapshot not being called

    I'm trying to get Table.onEndOfSnapshot to be called once a snapshot has been sent. In the Portfolio demo that comes with Lightstreamer (pages/demos/PortfolioDemo/portfolio.js), I inserted the following line:

    Code:
    table.setDataAdapter("PORTFOLIO_ADAPTER"); // first-level Data Adapter
    table.setUnderDataAdapter("QUOTE_ADAPTER"); // second-level Data Adapter
    table.setSnapshotRequired(true);
    table.setPushedHtmlEnabled(false);
    table.onEndOfSnapshot = function(itemPos, itemName) {
    	alert('end of snapshot');
    };
    I was expecting to get an alert when the snapshot was sent. But nothing happens.

    In the server's log file, I do see this:
    Code:
    portfolio1: snapshot sent
    which is sent by the PortfolioDataAdapter Java class, right after it calls listener.smartEndOfSnapshot().

    Does anyone know why onEndOfSnapshot isn't being called?

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,090
    A bug affecting snapshots was fixed on the portfolio demo Data Adapter about one year ago
    and released with Server version 3.5 build 1422.
    Is it possible that you are using an older version?
    Before the fix, the EndOfSnapshot signal were issued only upon the first real-time update of the portfolio composition.

  3. #3
    Member
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    9
    I have Moderato version 3.5 build 1428.4. I just downloaded it about a week ago. The following behavior happens pretty consistently:

    1. Start the server.
    2. Load the Portfolio Demo. No alert appears. The page starts receiving real-time updates.
    3. Submit an "order" for any quantity of any stock.
    4. The alert appears, right after I submit the order.
    5. Reload the page. This time the alert appears immediately after the data loads, as it should.

    Thanks,
    Jacob

  4. #4
    Member
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    9
    I should also add that I first noticed this behavior with my own metadata/data adapters. So it's not limited to just the Portfolio demo.

  5. #5
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,090
    I have found an error in our distribution process,
    so the predeployed portfolio demo jars were not updated after the abovementioned fix.
    However, the copies of the same jars under
    DOCS-SDKs\sdk_adapter_java\examples\Portfolio_Adapters\ Deployment_LS\Portfolio\lib
    did get updated.
    Hence, you can refresh the two jars in adapters\Demo\portfolio\lib with the corresponding ones under the DOCS-SDKs tree.

  6. #6
    Member
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    9
    Thanks! That did the trick. And to correct my last post, this wasn't happening with my own adapters; I was just using the Portfolio adapters with my own JavaScript. So problem solved.

  7. #7
    Member
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    9
    One more question on this topic. That onEndOfSnapshot function gets called when the main table's snapshot is finished, which is when all rows have been added to the table. But at that point, the rows are mostly empty.

    As I understand it, each row gets its own subscription, and its own snapshot. So after onEndOfSnapshot is called, you'll get an update for each row, with a CHANGE command, and itemUpdate.isSnapshot set to true.

    What's the best way to detect when all of those snapshots have been received? I'd like to know when the table is fully populated with data, not just when it has the names of all the row items. I can think of two ways:

    1) Look for the first update where isSnapshot is false. This seems to only happen after all of the rows' snapshots have been received, but I'm not sure whether that's guaranteed to be the case. Also, this means you have to wait for the first non-snapshot update before you can know that the snapshot is done.

    2) Count the number of rows that were ADDed, and wait until you get an UPDATE with isSnapshot=true for each one. This seems more reliable, although it involves more work on the client side.

    Or is there a way to listen for the onEndOfSnapshot for each individual row's table?

    Thanks,
    Jacob

  8. #8
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,090
    You are referring to a MultiDynaMetapushTable, which implements two level push.
    Indeed, the onEndOfSnapshot notice refers to the first level,
    i.e. the COMMAND mode item that governs the table structure;
    if there is any custom operation that you have to perform anytime the table structure changes,
    this lets you know when the table initial population has completed,
    so that you can perform your custom operation only once in the population phase.

    However, no notification is available when the table contents are completely filled.
    Note that a normal OverwriteTable made of multiple lines also lacks this information.

    Your analysis is correct. Technique number 2 can be used, whereas there is no guarantee that technique number 1 will work.
    onEndOfSnapshot for the individual rows is not provided, as the second level items are always subscribed to in MERGE mode, hence referring to the isSnapshot method is enough.
    Admittedly, the documentation for isSnapshot is not clear enough for the MultiMetapush case and will be expanded. However, the method behaves as you described.

  9. #9
    Member
    Join Date
    Jul 2009
    Location
    San Francisco
    Posts
    9
    Dario -- thanks again for all your help.

  10. #10
    Member
    Join Date
    Dec 2006
    Location
    Colorado Springs
    Posts
    7

    All Data Has Been Pushed?

    Have a few questions related to the end of snapshot / whether all of the data has been pushed:

    1) It looks like the only functional difference between onEndOfSnapshot and OnSnapshotEnd (Lightstreamer .NET Client version) is the removal of itemPos. Is this correct? Do they essentailly provide the same functionality?

    2) The onEndOfSnapshot (using COMMAND) only seems to trigger when a client first makes a connection to Lightstreamer. If it is a new subscription, it triggers before any of the items are sent. If it the subsciption is being reused, it triggers after all of the items are sent. This is because the snapshot is only data that has accumulated before subscription time, yes?

    3) So is there a way to tell when all of the items an adapter is passing to a client have been recieved? The onEndOfSnapshot seems to work ONLY if the subscription had already been made and only on init (not for any updates). This answer was unclear from the previous post since a two level push was used and this is just referring to the 'one level push'. An alternative would seem to be to have Lightstreamer send the number of upcoming pushes beforehand and then do a count on the client side.

    Thanks.

 

 

Similar Threads

  1. Subscribing to the Table
    By AidasOzelis in forum Client SDKs
    Replies: 13
    Last Post: June 3rd, 2010, 02:13 PM
  2. Error: createEngine() has already been called
    By vaduganathan in forum Client SDKs
    Replies: 3
    Last Post: April 9th, 2010, 09:58 AM
  3. notifySessionClose sometimes not being called
    By lstest in forum Adapter SDKs
    Replies: 2
    Last Post: February 24th, 2010, 12:09 PM
  4. Update Table
    By EWANG in forum Client SDKs
    Replies: 1
    Last Post: August 19th, 2009, 11:17 AM
  5. Data Adapter's subscribe() method not getting called
    By CitiMan in forum Adapter SDKs
    Replies: 8
    Last Post: November 30th, 2006, 05:26 PM

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 11:02 PM.