Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Nov 2006
    Location
    Riyadh
    Posts
    33

    Returning dynamic list of stockItems

    Hi all,

    We are evaluating Lightstreamer product for stock streaming and I have the following issues:

    1) I made an adapter which reads the stock data from an io stream (file/socket) and it works

    2) I made a meta adapter which does the following:
    - Client (in my case I use the java client for testing and use ExtendedTable/SimpleTable) subscribes to two items named "List.1" and List.2". These are not stock items, but aliases to multiple stock items
    - When getItem gets invoked in the meta adapter, it uses the "user" and a property file to return an array of stock items. For instance, in the file, I have :
    user.stocklist.List.1=item1 item2 item3
    user.stocklist.List.2=item4 item5
    - The reason for this is to allow the end-user subscribe to stock items and have lightstreamer keep the list at the backend-side.

    3) In the logging from the adapter, lightstreamer does indeed subscribe each returned stockitem to the data adapter. For instance:

    = MetaProvider.getItems(): user=_default_ - id=List.2 - items=2290 4040 4061
    = StockDataAdapter.subscribe(): itemName=2290
    = StockDataAdapter.subscribe(): itemName=4040
    = StockDataAdapter.subscribe(): itemName=4061

    4) However, the client does not know how to handle it (either using ExtendedTable.subscribeTable or subscribeItems). Whenever onUpdate gets invoked, it seems to expect an item named "List.1" or "List.2". The client fails with "Wrong Item Number".

    5) So I modified ExtendedTableInfo to get rid of the exception, and now it runs but without much success anyway. The client displays:

    = update for List.1: {bid_quantity=3641}
    = update for List.1: {ask_quantity=9959}
    = update for List.2: {ask_quantity=9959}
    = update for List.1: {bid_quantity=6913}
    = update for List.1: {ask_quantity=10037}

    When I expect it to return item1,2,3,etc instead of List.1 or List.2

    6) However, SimpleTableInfo seems to provide better results but the listener.onUpdate does not give me the itemName as returned by the data adapter, but gives me an item Number which I don't know to which stock it relates to...

    => So I am a bit confused. It seems as if the client must know all the items it needs to subscribe to and cannot simply specify an alias which would be resolved by the backend and return a dynamic list of items.

    => Also, I could not find a way to know the number of items effectively subscriber by the adapter or meta adapter given an input item which is an alias (List.1 or List.2). I need this to create the right number of table rows in the client gui (java or HTML).

    Any hint is highly appreciated.

    R

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    Please take first a look at this post.
    If you want to use aliases instead of item names you must use a SimpleTableInfo object. Then you must listen for updates on your own implementation of SimpleTableListener. This way you don't receive item names on the onUpdate callback but item indexes.

    So:
    => So I am a bit confused. It seems as if the client must know all the items it needs to subscribe to and cannot simply specify an alias which would be resolved by the backend and return a dynamic list of items.
    This is partially true, since if you want to receive updates with item names you must know them client side and so you can do it via ExtendedTableInfo, btw you can use aliases and receive updates with item indexes via SimpleTableInfo.

    => Also, I could not find a way to know the number of items effectively subscriber by the adapter or meta adapter given an input item which is an alias (List.1 or List.2). I need this to create the right number of table rows in the client gui (java or HTML).
    This is also true, if you don't know how many items an alias correspond to, you must create your GUI dinamically adding a new row each time a greater index arrives to the onUpdate callback. Note that indexes always start from 1.


    Hope that helps,
    Mone.

  3. #3
    Senior Member
    Join Date
    Nov 2006
    Location
    Riyadh
    Posts
    33
    Thanks for the details. I already figured this out when using the HTML client, the items were added dynamically in a specific order.

    However, I need to know if the order assigned to each item is the same as the order returned by the MetaAdapter.getItems ? That would help keep the same order to the end-user as it is stored in the backend DB.

    2) Also, I'd like to know how can I manage Single-Singon ?
    Basically, suppose I am using Apache to authenticate the user and manage HTML pages.
    Lightstreamer would be a standalone instance only serving push information.
    How can I automatically have Lightstreamer authenticate the same Apache user without prompting for the user/password again ?

    Regards,
    R

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Quote Originally Posted by rsouissi
    However, I need to know if the order assigned to each item is the same as the order returned by the MetaAdapter.getItems ?
    Yes of course, item 1 client side is the first item in the array returned by your getItems.

    Quote Originally Posted by rsouissi
    2) How can I automatically have Lightstreamer authenticate the same Apache user without prompting for the user/password again ?
    There are different ways to handle login.
    In example you could - once logged into Apache - return to the client a server-side-dynamic (php, jsp, asp) page including calls to setUserName and setPassword configured to log-in the web client into LS.

    Keep in mind that each time an application sends to LS a user/password pair you will receive a call to notifyUser, this will allow you to check on your MetadataProvider if a user can open a new LS session or not. Implement notifyUser as an empty function will allow all user/password to open a session. Moreover once the user is logged in you can control which items he can subscribe with the notifyNewTables calls.

    Let me know if something is unclear or have a more specific question.
    Bye.

  5. #5
    Senior Member
    Join Date
    Nov 2006
    Location
    Riyadh
    Posts
    33
    Thanks for the reply,

    1) If I allow the server side to generate a client code which sets the user and the password, I would be exposing the password as plain text in the client HTML page, even if SSL is used. Which is a security issue.

    What I tought maybe is the following:
    - Apache authenticates user and creates a session cookie maintained by the client browser. Back-end saves the session in the DB and assigns to it the username the client used.
    - Client uses the lightsteamer which create a new lightstreamer session, same as Apache. Lightstreamer meta adapter looks up the session from DB and resolves the username.

    But it seems the session id create by lightstreamer has nothing to do with the browser HTTP session, right ?

    Any other technique that can do a better job ?

    2) I am not sure I understand the use of notifyNewTables(). If I want to restrict a user into accessing only his items, I can rely on getItems(), right ?

    3) New question: If two lightstreamers must be used for loadbalancing and high availability, do they have to get their stream data independantly or can they share the same source (I assume the source cannot broadcast to two targets and I do not have my own message broker to publish/subscribe). Is this the reason for the remote adapers ? Is this the only way ?

    4) New question: is it possible to start lightstreamer server without a network connection ? It seems it always needs it to check the license remotely, but this handicapes me quite often either because I use dialup where I am or because of proxy/firewall blocking your IP...

    5) New question: sendMessage() is good to notify MetaAdapter but sometimes we might need to use it in request/reply mode (basically expect answer back). Is this possible somehow ? I thought maybe to get the client to subscribe to a special item identified by a random unique id where the replies would come thru, but this looks as a hack to me.

    Regards,
    R

  6. #6
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    975
    Hi Riad

    Quote Originally Posted by rsouissi
    1) If I allow the server side to generate a client code which sets the user and the password, I would be exposing the password as plain text in the client HTML page, even if SSL is used. Which is a security issue.

    What I tought maybe is the following:
    - Apache authenticates user and creates a session cookie maintained by the client browser. Back-end saves the session in the DB and assigns to it the username the client used.
    - Client uses the lightsteamer which create a new lightstreamer session, same as Apache. Lightstreamer meta adapter looks up the session from DB and resolves the username.

    But it seems the session id create by lightstreamer has nothing to do with the browser HTTP session, right ?

    Any other technique that can do a better job ?
    Lightstreamaer Server does not check for session cookies in the HTTP requests it receives.
    However, you can pass the session cookie content to setUserName (and ignore setPassword); the session cookie is already visible on the client side, so this should not affect security.
    Then, as you remarked, the Metadata Adapter has to lookup the session cookie and find the associated "real" user in order to decide whether to allow or restrict the access.
    This is the commonly used technique.
    The session id created by Lightstreamer is indeed only for internal use.

    Quote Originally Posted by rsouissi
    2) I am not sure I understand the use of notifyNewTables(). If I want to restrict a user into accessing only his items, I can rely on getItems(), right ?
    Yes, the notifyNewTables() method has been made available only to allow a server-side check on the overall subscription activity within a session.
    For example, it can be used to prevent the user from opening too many popup windows.
    If a specific item cannot be subscribed to by a user, the client page logic and the getItems() method should disallow it.

    Quote Originally Posted by rsouissi
    3) New question: If two lightstreamers must be used for loadbalancing and high availability, do they have to get their stream data independantly or can they share the same source (I assume the source cannot broadcast to two targets and I do not have my own message broker to publish/subscribe). Is this the reason for the remote adapers ? Is this the only way ?
    May you please clarify what do you mean by two Server instances that "share the same source?".
    The Remote Adapters were not introduced because of this kind of requirements and indeed each Remote Server instance is meant to feed exactly one Lightstreamer Server instance.

    Quote Originally Posted by rsouissi
    4) New question: is it possible to start lightstreamer server without a network connection ? It seems it always needs it to check the license remotely, but this handicapes me quite often either because I use dialup where I am or because of proxy/firewall blocking your IP...
    If you own a trial account, then a license check is performed at each Server startup and this requires a brief connection to the remote license server.
    The connection to the remote license server is a simple HTTPS connection and we assume that it should not be blocked by firewalls.
    If the Server is behind a proxy, then it can be configured in order to properly access the proxy (see the lightstreamer_conf.xml file).
    If you own a Dev/Test/Prod/Demo license, on the other hand, no connection to the remote license server is needed.

    Quote Originally Posted by rsouissi
    5) New question: sendMessage() is good to notify MetaAdapter but sometimes we might need to use it in request/reply mode (basically expect answer back). Is this possible somehow ? I thought maybe to get the client to subscribe to a special item identified by a random unique id where the replies would come thru, but this looks as a hack to me.
    As Lightstreamer Server is meant to always stand beside a Web Server, the management of any request/reply behaviour can be left to the Web Server.
    The sendMessage() method was introduced only as a shortcut for simple cases, but even our interactive demos, like the Interaction Demo are based on servlets for the management of the user input.

    Dario

  7. #7
    Senior Member
    Join Date
    Nov 2006
    Location
    Riyadh
    Posts
    33
    >> May you please clarify what do you mean by two Server instances that "share the same source?".

    What I meant, in case I have one single source of data feed (actually a socket stream) and I want to run two instances of lightstreamer feeding from this source at the same time, can this be done easily ? In fact, I prefer not to use a message broker in the middle...

    >> If you own a Dev/Test/Prod/Demo license, on the other hand, no connection to the remote license server is needed.

    How can I obtain a demo license ?

    Thanks for your help,
    Regards,
    R

  8. #8
    Administrator
    Join Date
    Jul 2006
    Location
    Milan, Italy
    Posts
    517
    Quote Originally Posted by rsouissi
    What I meant, in case I have one single source of data feed (actually a socket stream) and I want to run two instances of lightstreamer feeding from this source at the same time, can this be done easily ? In fact, I prefer not to use a message broker in the middle...
    You have to send the data flow to both the LS Server instances. So the only options are that your data feed sends the flow two times (on two sockets) or that you actually use a messagre broker.

    Quote Originally Posted by rsouissi
    How can I obtain a demo license ?
    Demo licenses are usually released to Lightstreamer customers and partners. If you actually need a demo or development license, please send an email to info@lightstreamer.com, so that a personal discussion can be done.

    Cheers

 

 

Similar Threads

  1. SSL certificate compatibility list
    By anselme in forum General
    Replies: 6
    Last Post: February 12th, 2013, 04:46 PM
  2. Add dynamic data in Server and update it to Client
    By giangum in forum Client APIs
    Replies: 1
    Last Post: September 1st, 2009, 10:20 AM
  3. Unexpected empty selected list
    By shreyaspurohit in forum Adapter APIs
    Replies: 4
    Last Post: April 14th, 2009, 11:38 AM
  4. Stock List Adapter
    By minhphan200677 in forum Adapter APIs
    Replies: 1
    Last Post: April 14th, 2008, 10:26 AM
  5. Dynamic Content
    By venkihere in forum Client APIs
    Replies: 7
    Last Post: October 12th, 2007, 02:14 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 07:02 AM.