Results 1 to 8 of 8

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jul 2013
    Posts
    39

    Suspend/resume subscription

    Hi,

    Are there functions like suspend/resume for subscription?

    When "suspend" a subscription, LS server does not send update data to client. When "resume", LS server will send only new data since last update to client.

    As I understand at this moment, I have to unsubscribe to stop receive update data from server, and then re-subscribe and get all data as snapshot. I think LS client can utilize client cache to save network bandwith.

    Thanks.

  2. #2
    Senior Member
    Join Date
    Feb 2013
    Posts
    54
    Hi,

    No, there isn't a functionality like a subscription suspension, which will send, when the subscription is resumed, only the new data since the last message sent before the suspension.
    You can only unsubscribe an item and subscribe it again, but in this case you may receive as snapshot also messages received in the previous subscription session.
    Maybe it is sufficient for your scenario to reduce the message frequency and than increase it again. In this case you may still receive messages but most of them will be received when the frequency is set to high.


    hth
    Marco

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Posts
    39
    Thanks Marco,

    From my point of view, such suspend/resume functions can give much benefits, esspecially for mobile app: less network traffic (save battery), don't have to wait for receiving data to render UI (we will instantly display last snapshot, then update UI when receive only new data). Those functions may be used frequently according to mobile device pauses/resumes.

    And implementing them is not difficult, is it? Please consider that feature.

    Regards,

    P/S: sorry I post this question in wrong place. Please move this thread to JavaScript Client API or Architecture-Integration-Deployment forum. Thanks.
    Last edited by tvhnet2013; August 28th, 2013 at 07:25 AM.

  4. #4
    Senior Member
    Join Date
    Feb 2013
    Posts
    54
    Hi,

    The question is for how long the client is supposed to suspend the subscription, because a session cannot last long.
    let me recap your scenario and see if I've correctly understood.
    - The client connects to the LS Server, subscribes to an item, and receives the snapshot and than all the updates.
    - at a certain point the client decides to suspend the subscription because it goes in background or even stops, but in any case it is able to retain the last snapshot of the received data.
    - after a while, that can be minutes or also hour, the client resumes, and it wants to receive only the date not received in the previous session.
    The key point in this scenario is the fact that the client is actually closing the old session and opening a new one, but wants to receive only the data not received in the previous session.
    Am I correct?
    This reminds me a sort of synchronization between the client and the LS Server where both agree on which was the last sent data.

  5. #5
    Senior Member
    Join Date
    Jul 2013
    Posts
    39
    Thanks Marco,

    - The client connects to the LS Server, subscribes to an item, and receives the snapshot and than all the updates.
    - at a certain point the client decides to suspend the subscription because it goes in background or even stops, but in any case it is able to retain the last snapshot of the received data.
    - after a while, that can be minutes or also hour, the client resumes, and it wants to receive only the date not received in the previous session.
    Correct.

    The question is for how long the client is supposed to suspend the subscription, because a session cannot last long.
    We can have a timeout option for this case.

    The key point in this scenario is the fact that the client is actually closing the old session and opening a new one, but wants to receive only the data not received in the previous session.
    I don't understand clearly about closing/opening session here. Do you mean network connection session? If so, new session still knows about subscribed items from the old one. Now, it should know more about "receive state" of such items.

    This reminds me a sort of synchronization between the client and the LS Server where both agree on which was the last sent data.
    Yeah, that's about synchronization. That can auto make between LS client and server internally or you can provide new API at client to let developer ask server.
    Last edited by tvhnet2013; August 29th, 2013 at 03:24 AM.

  6. #6
    Senior Member
    Join Date
    Feb 2013
    Posts
    54
    Hi,

    First of all, just to be sure, I assumed we are talking about a DISTINCT subscription type, am I right?
    In Lightstreamer there is not such a feature already built in, but you can maybe implement it relatively easily on top of Lightstreamer, using selectors.
    The Item should have a counter field, which holds a sequence number incremented for each ItemEvent.
    The idea is to subscribe an item specifying a selector. A selector is a string, representing a name or a predicate, which will be used by the Metadata Adapter to determine if an ItemEvent should be filtered. In this case the selector should bear the latest sequence number received by the client: something like "SequenceNum=213258".
    You have to implement the 'isSelected' method in your MetadataProvider, where you compare the sequence number of the ItemEvent whit the seq num of the selector, to determine if the item was already sent to the client and in case avoid to send it again.
    By the way you have to be aware that the 'isSelected' method is called for every itemEvent entering the ItemEventBuffer, before being sent to the client, and not just the ItemEnets of the snapshot, therefore the 'isSelected' method should perform fast, and must be implemented carefully, to avoid to slow down the whole update delivery process.
    You may find more details in section 3.3.1 of General Concepts , in the description of method setSelector of Lightstreamer JavaScript Client 6.0.1 API and the method 'isSelected' of the MetadataProvider interface in 'Java Adapter API Reference'


    hth,
    Marco

  7. #7
    Administrator
    Join Date
    Jul 2006
    Location
    Milan, Italy
    Posts
    516
    Hi tvhnet2013,

    It seems that what you mean by suspend/resume directly matches disconnect/connect in the Lightstreamer jargon.

    When you disconnect, all the current subscriptions are automatically remembered for next time you call connect.
    Please see http://www.lightstreamer.com/docs/cl...tml#disconnect

    Cheers,
    Alessandro

  8. #8
    Senior Member
    Join Date
    Jul 2013
    Posts
    39
    @Marco: thank you so much. I will study selector as your suggestions.

    @Alessandro: My idea is to suspend/resume some subscriptions only.

 

 

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:27 PM.