Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    Hello,
    In previously I have subscribed clients with server using the prefix string as Item for every row key
    @
    Override public void subscribe(String itemName) throws SubscriptionException, FailureException {
    logger.debug("Subscribing to " + itemName);
    if (itemName.startsWith("Item")) {
    myFeed.sendRates(itemName);
    }
    }
    I have used above method to subscribe clients with server.

    In my client I have used like
    var liverateId = "Item";
    var liverateSubscription = new Subscription("COMMAND",liverateId,fieldList);
    liverateSubscription.setDataAdapter("ABQUOTE_ADAPT ER");
    liverateSubscription.setRequestedSnapshot("yes");
    liverateSubscription.addListener(liverateGrid);
    lsClient.subscribe(liverateSubscription);
    So it was easy to get subscribe the items from my server. Previously I have created individual adapter so that it was was easy to get connect. Now I have created single adapter for all of my clients.
    And my structure looks like now is,
    [{"com_id":"33","com_name":"GOLD BAR","selling_rate":"4952","buying_rate":"-","delivery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrad e_33 "},{"com_id":"36","com_name":"GOLD FT","selling_rate":"4952","buying_rate":"4751"," de livery":"30-06-2020","retail_rate":"-","client":"lmxtrade","client_com_id":"lmxtrad e_36 "},{\"com_id\":\"36\",\"com_name\":\"GOLD FT\",\"selling_rate\":\"4943\",\"buying_rate\":\" 4 841\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\" kkv trade_36\"},{\"com_id\":\"38\",\"com_name\":\"SILV ER\",\"selling_rate\":\"48455\",\"buying_rate\":\ " 48428\",\"delivery\":\"30-06-2020\",\"retail_rate\":\"-\",\"client\":\"kkvtrade\",\"client_com_id\":\" kkv trade_38\"}]
    Here my key is client_com_id field. Now how I need to connect LS server from my client. Can you please help me on this.

  2. #12
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    716
    Is your client aware of its typology? Ie. it can do something like this:

    Code:
    var liverateId = "lmxtrade"; // 
    var liverateSubscription = new Subscription("COMMAND",liverateId,fieldList);
    liverateSubscription.setDataAdapter("ABQUOTE_ADAPT ER");
    liverateSubscription.setRequestedSnapshot("yes");
    liverateSubscription.addListener(liverateGrid);
    lsClient.subscribe(liverateSubscription);
    If yes the subscribe method should be something similar to this:

    Code:
    Override public void subscribe(String itemName) throws SubscriptionException, FailureException {
    logger.debug("Subscribing to " + itemName);
    if (itemName.startsWith("lmxtrade")) {
     // push only "client":"lmxtrade" elements
     } else if (itemName.startsWith("kkvtrade")) {
     // push only "client":"kkvtrade" elements
     }
    }

  3. #13
    Power Member
    Join Date
    Sep 2013
    Location
    Coimbatore
    Posts
    121
    This client name will be more than 100. like lmxtrade, kkvtrade, svg, sln etc.

    For this only i'm thinking how to use this in this case. I'm storing this client name in redis. So I can get array of clients in LS server. Can I check itemName.startsWith array of item.

    Now I have client list as ["lmxtrade", "kkvtrade", "vb", "lmx", "svg", "kb", "sln"]

    List<String> list = myFeed.getClientsList();
    for (int i = 0; i < list.size(); i++) {
    if (itemName.startsWith(list.get(i))) {
    myFeed.sendRates(itemName);
    }
    }
    I have written the subscription logic as like this, is this okay to subscribe client with LS server.

    In previously I have given OnUpdate, OnAdd and OnDelete static name as "Item"
    private void onUpdate(Object handle, String key, ClientsRateRow rates) {
    // An update was received from the feed
    // Check for late calls
    // if (isSubscribed(handle)) {
    // Create a new HashMap instance that will represent the update
    HashMap<String, String> update = new HashMap<String, String>();
    // We have to set the key
    update.put("key", key);
    // The UPDATE command
    update.put("command", "UPDATE");
    // And the new quantity value


    update.put("desc", rates.getCom_name());
    update.put("bid", rates.getBuying_rate());
    update.put("ask", rates.getSelling_rate());
    update.put("low", rates.getLow_rate());
    update.put("high", rates.getHigh_rate());
    update.put("delivery", rates.getDelivery());
    update.put("retail_rate", rates.getRetail_rate());
    update.put("comweight", rates.getCom_weight());
    update.put("comid", rates.getCom_id());
    update.put("order", rates.getCom_order());


    // Pass everything to the kernel
    // listener.smartUpdate(handle, update, false);
    listener.update("Item", update, false);
    // }
    }
    Whether I have to change Instead of Item I need to change anything. Please help me on this struggling from last week.
    Last edited by rvkvino; July 6th, 2020 at 10:06 AM.

 

 

Similar Threads

  1. how many server adapter are created?
    By josephpanchal in forum General
    Replies: 1
    Last Post: October 21st, 2019, 10:35 AM
  2. Creating adapter for dynamic stock list
    By rvkvino in forum General
    Replies: 1
    Last Post: February 14th, 2017, 10:22 AM
  3. how many server adapter are created?
    By brunovaghi in forum General
    Replies: 1
    Last Post: September 30th, 2016, 09:58 AM
  4. Snapshot in Remote Data Adapter
    By Dejan Milosevic in forum Adapter SDKs
    Replies: 5
    Last Post: July 31st, 2014, 04:06 PM
  5. Add dynamic data in Server and update it to Client
    By giangum in forum Client SDKs
    Replies: 1
    Last Post: September 1st, 2009, 10:20 AM

Tags for this Thread

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 12:55 PM.