Results 1 to 4 of 4
  1. #1

    Handle Different Subscription Types For the Same ItemName (DataAdapter)


    I have a question regarding the Subscribe method of the DataAdapter.

    As it currently stands, we pass in a simple string for the item that we wish to subscribe to.

    This is simple enough. In my case, I want to subscribe to contracts, so we pass in a contractId (ie, 1234).

    The problem we have is that in our case, this contract will have multiple types of updates that not every user is interested in. For example, one user may want prices for this contract, while another may want bids.

    Since Subscribe only takes in a simple string argument, how can we determine what type of subscription the user wants for this contractId?

    My initial thought is that we have to pass the type information in through the itemName parameter, and parse it out.

    For example:
    public void Subscribe(string itemName)
             //itemName = "bids:1234" (type:contractId)
             var split = itemName.Split(':');
             var  type = split[0];
             var contractId = split[1]
             if (type == "bids")
             else if (type == "prices")
    Is this the best way to do this? Or is there a better option?

  2. #2
    Join Date
    Feb 2012
    Hi Tanner,

    When a client subscribes to an Item it should also specify s list of fields of which is interested in receiving updates.
    Each client can specify a different subset of fields among all available fields for that Item; and it will be the responsibility of the Lightstreamer server to provide each client with only the updates pertaining to the requested field list.

    But we are aware that this kind of granularity may not suit all scenarios. For example take a look a this demo ( the source code here:
    In this case we have chosen to make three subscriptions to three different Items for each Stock.
    A Subscription containing 1 item, subscribed to in MERGE mode feeding a StaticGrid (showing summary data for the stock).
    Two Subscriptions containing 1 item each, subscribed to in COMMAND mode feeding two DynaGrids (showing the bid and ask lists).
    In this case one of the main reasons to divide the subscriptions into three is also the different mode required for the Items, MERGE in the first case and COMMAND for the other two.

    Please let us know if you need any further clarifications.


  3. #3
    Hi Giuseppe,

    Thanks for taking the time to reply.

    I understand what you are saying, that makes sense. I think your scenario of just not listening to the unwanted fields would make sense if we had just one system providing updates on our backend. However, in our scenario, there is some additional complexity in the fact that Bid and Price updates come from different places. As such, we only want to make subscriptions to the sources on the backend if lightstreamer has clients listening to these fields on the front end. Hopefully that makes sense.

    It looks like in the demo you are provided, you are essentially doing what I was suggesting? So, you are subscribing to <stock>_BUYSIDE, <stock>_SELLSIDE, etc. Both of those items get different types of updates/information for the same stock. This is essentially what I was suggesting when I mentioned doing something like "prices:1234" and "bids:1234". Different updates/info subscriptions for the same contract.

    I just wanted to clarify if there was a better way to do this, but from that demo is seems like this is viable solution?


  4. #4
    Join Date
    Feb 2012
    Hi Tanner,

    Yes you are right, I confirm that in cases like yours, when the type of information is very different or the external data sources are different, splitting the information on several Items makes total sense.




Similar Threads

  1. Replies: 4
    Last Post: June 1st, 2015, 10:25 AM
  2. Replies: 3
    Last Post: May 9th, 2014, 07:56 AM
  3. Uniqueness of Itemname
    By LS_Developer in forum Adapter SDKs
    Replies: 1
    Last Post: June 10th, 2011, 05:21 PM
  4. Replies: 0
    Last Post: February 17th, 2010, 05:10 PM
  5. Replies: 5
    Last Post: February 4th, 2010, 09:55 AM


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:41 AM.