Results 1 to 5 of 5
  1. #1

    Register with Command only to "ADD" and "REMOVE"

    Hi,

    I'd like to know if it's possible to subscribe using Command and receive only "ADD" and "REMOVE" (without "UPDATE").

    For example,
    If I have the following COMMAND stream:
    ID Field 1 Field 2
    1 TEST1 TEST2
    2 TEST1 TEST2
    3 TEST1 TEST2

    I want to receive an update from Lightstreamer only when the following row was added:
    4 TEST1 TEST2

    And I don't want to receive an update when the following row changed
    2 TEST7 TEST2

    Hope you understood.

    Thanks,
    Lidan.

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


    The solution should be to prevent the server sends updates, but I assume you are not allowed to change the behavior of the adapter.
    Unfortunaltelly it is not possible to subscribe only INSERT and DELETE messages but not UPDATEs.
    Client side a solution could be to avoid to change the grid values when the client receives an update, but this is just a patch, and a tricky one, so let me know if you decide to follow this path.


    regards
    Marco

  3. #3
    Quote Originally Posted by marco.testa View Post
    Hi Lidan,


    The solution should be to prevent the server sends updates, but I assume you are not allowed to change the behavior of the adapter.
    Unfortunaltelly it is not possible to subscribe only INSERT and DELETE messages but not UPDATEs.
    Client side a solution could be to avoid to change the grid values when the client receives an update, but this is just a patch, and a tricky one, so let me know if you decide to follow this path.


    regards
    Marco
    Hey Marco,

    Thanks for your input.
    I forgot to mention that the entire idea is that there are a lot "UPDATE" commands and I don't want to receive them because of the traffic it causes.
    In this specific scenario I only care about ADD/REMOVE. But on other Scenarios I would want to receive the UPDATE as well.

    If I understood you correctly, there is no way doing that without editing the server code. Please confirm.

    Thanks,
    Lidan.

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

    Yes, the client is not able to subscribe only Create or Delete messages but not Updates, so, in order to actually avoid to send Update messages to a client not interested to them, you have to act on the Adapter. Otherwise the client may ignore the Update messages, but this means the messages are still sent and thus use network bandwidth.
    From the Adapter point of view there are three possible solutions I can think of.
    The first proposed solution is based on the "two-level push" (you may take a look at the Portfolio Demo at http://www.lightstreamer.com/demos#PortfolioDemo for an example).
    In this case there are actually two distinct Data Providers: one that sends Add or Remove commands for items being added or removed from a basket, carrying the item key and static field, and the other actually sending the volatile fields, thus sending update messages when an item changes.
    If a client is not interested at receiving updated values, but it's just interested at receiving a message when an item has been added or removed, it may subscribe only to the first Data Adapter.
    The second proposed solution involves the use of a Selector. The Client can specify a selector through the setSelector() function and the Metadata Adapter decides whether an event should be delivered to that session based on the specified selectior string.
    You have to extend the Metadata Adapter, implementing the 'isSelectorAllowed' and 'isSelected' methods.
    In this case Items can be selected based on the "command" filed of the ItemEvent. Note that it's up to the selector to ensure the suppression of events is "consistent with keys lifecycle,
    ensuring that ADDs and DELETEs on the same key are interlaced (always starting with an ADD, if the snapshot has been requested) and that UPDATEs follow ADDs for the same key, but not DELETEs". For more details you may look at chapter 3.3.1 in "Lightstreamer General Concepts" http://www.lightstreamer.com/latest/...20Concepts.pdf and on the forum at http://forums.lightstreamer.com/show...sing-selectors.
    The third proposal is to duplicate the items: for a given item the client may subscribe to a key where all commands are sent, or it may subscribe to an other key where only Create and Delete are sent. In other words, if an item is added on or delete from the Data Provider, the Data Adapter actually sends the command with two different topics, while instead, if an item is updated on the Data Provider, the Data Adapter sends the Update message only for one topic.
    This is not actually very elegant but it's simple.


    HTH
    Marco

  5. #5
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Hi Lidan,

    I am not sure if this fit your requirements or not, but you can also set for the specific clients a very low frequency limit.

    Please refer to setRequestedMaxFrequency client method to further details. In this case you will receive ADD and DELETE events as usual, but the UPDATE events with very low frequency. Obviously, as Marco said, you can not completely avoid to receive them.

    Please note that by setting the frequency limit you give up the "unfiltered" management and then, in special scenarios, two events of ADD and DELETE (for the same key) can be merged together and result in no sending.

 

 

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 05:02 AM.