Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    May 2011
    Location
    test
    Posts
    1

    Automatic subscribe to different items

    Hello

    In the hello world example the subscribe method starts specific thread

    public void subscribe(String itemName, Object itemHandle,
    boolean needsIterator)
    throws SubscriptionException, FailureException {
    if (itemName.equals("greetings")) {
    gt = new GreetingsThread(itemHandle);
    gt.start();
    }
    }

    we are trying to start the thread in init method so even if the subscribe method is not called the thread should run on server side processing the data

    public void init(Map params, File configDir) throws DataProviderException {

    }
    The problem we are getting with the itemHandle Object

    can anyone provide a snippet of code to call the thread in init method, as we tried in init method but giving error on server console for the itemHandle object in
    listener.smartUpdate function

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    973
    I suppose that your thread communicates with an external feed to receive updates it will forward to Lightstreamer Server through "smartUpdate";
    in this case, you can start it from "init", but you should take care of not calling "smartUpdate" (hence discarding the updates) until "subscribe" is invoked by the Server.
    Only upon "subscribe" will you enable the thread to invoke "smartUpdate" and, while doing that, you will get the "itemHandle" needed by "smartUpdate" and pass it to your thread.
    Eventually, upon "unsubscribe", you will prevent the thread from invoking "smartUpdate" again.

    Alternatively, you could invoke "update" in place of "smartUpdate".
    With "update", the "itemHandle" is not needed and the involved item is identified by the item name.
    In this case, you could invoke "update" regardless that "subscribe" has been invoked, but note that in this case the Server will discard the update and will issue a warning message in the log.

 

 

Similar Threads

  1. Non-blocking IDataProvider.Subscribe
    By bartol82 in forum Adapter APIs
    Replies: 1
    Last Post: August 30th, 2011, 10:15 AM
  2. Client validation inside subscribe call
    By antiGuru in forum Adapter APIs
    Replies: 1
    Last Post: February 5th, 2010, 09:55 AM
  3. dynamically subscribe items
    By rd2008 in forum General
    Replies: 9
    Last Post: October 10th, 2008, 10:38 AM
  4. subscribe to items not using threads
    By nagakumaran in forum Adapter APIs
    Replies: 6
    Last Post: October 16th, 2007, 02:11 PM
  5. Data Adapter's subscribe() method not getting called
    By CitiMan in forum Adapter APIs
    Replies: 8
    Last Post: November 30th, 2006, 04:26 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 12:41 PM.