Results 1 to 5 of 5

Hybrid View

  1. #1
    Hey, thank you for your reply. Yeah, the thread is calling a blocking command because I have a timeout mechanism that gives the new client only a certain amount of time to reconnect. So its like::

    ClientListener:
    Code:
    case "DISCONNECTED":
        clientHandler.switchConnection()
    ClientHandler:
    Code:
    switchConnection():
    // configure client with new connections
    client.add(new ClientListener(CountDownLatch) )------> Upon receiving status "CONNECTED: WS-STREAMING" it counts down the latch
    client.connect()
    if (!countDownLatch.wait(timeoutTime)) {
        // throw error, couldn't connect
    }

  2. #2
    Since the Lightstreamer Client API is asynchronous, blocking its threads can have unexpected results.
    However you can set a timeout by using a java.util.Timer (or equivalent asynchronous mechanism).
    For example:

    Code:
    var client = new LightstreamerClient(...)
    Timer timer = new Timer();
    timer.schedule(() -> {
      if (!client.getStatus().startsWith("CONNECTED")) {
        client.disconnect();
      }
    }, TIMEOUT);
    client.connect();

  3. #3
    Right, ok. Well thank you for your help. I think at the end of the day I can't call my switch connection startup method directly from the listener because even if I do as you suggested with a timer then the server I am connecting to uses a chain of subscriptions (i.e. one subscription relies on processing the snapshot from the previous one) so I will need the dedicated listener thread to be available while going through the subscription process to receive the updates.

    Thanks!

 

 

Similar Threads

  1. Data source parsing problem
    By shabbirh in forum Client SDKs
    Replies: 2
    Last Post: September 28th, 2012, 10:00 AM
  2. Multithreading in Java Adapter
    By achittoda in forum Adapter SDKs
    Replies: 1
    Last Post: December 21st, 2009, 10:05 AM
  3. Newbe: LightStreamer and WSDL source for Adapter
    By Dr.Dran in forum Adapter SDKs
    Replies: 0
    Last Post: April 27th, 2009, 02:53 PM
  4. Interaction demo source code
    By sarbao in forum General
    Replies: 1
    Last Post: April 16th, 2009, 08:59 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:17 AM.