Jump to content
Sign in to follow this  
hellohello

how to subscribe to a channel using Java?

Recommended Posts

how to subscribe to a channel using Java?

 

sry I'm more of a hobby Programmer but maybe you can help me.

 

i try to get a "Prices Stream", but don't get any data:

public void runClientInBG() {
            LSClient lsc = new LSClient();
            ConnectionInfo ci = new ConnectionInfo();

            ci.adapter = "STREAMINGALL";
            ci.pushServerUrl = "https://push.cityindex.com";
            ci.user = ciapiClient.this.username;
            ci.password = ciapiClient.this.securityTocken;
            
            try {
                lsc.openConnection(ci, this);
                //154289  154297 154290
                SimpleTableInfo sti=new SimpleTableInfo("71442", "COMMAND", "MarketId",true){
                {
                    setDataAdapter("PRICES");
                }
                };
               lsc.subscribeTable(sti, this, true);
            } catch (Exception ex) {
                Logger.getLogger(ciapiClient.class.getName()).log(Level.SEVERE, null, ex);
                ex.printStackTrace();
            }
            
            
        }

Share this post


Link to post

Hi,

 

We don't have experience with the Java Lightstreamer client libraries so can't give the exact syntax. However, we've noted a few things:

 

1) To stream prices, you need to subscribe to a Prices stream with the marketID for that market you want the prices. PRICES.PRICE.{marketId}. See http://docs.labs.cityindex.com/#Streaming Data/Prices.htm%3FTocPath%3DCIAPI%2520Reference%7CStreaming%2520Data%7C_____5

 

2) Lighstreamer should be sent to "MERGE" and not "COMMAND".

 

3) The dataAdapter should be "STREAMINGALL" and not "PRICES".

 

One final suggestion is to set the Jave Lightstreamer library to DEBUG logging - its quite verbose and there might be a clue as to what is going on detailed in those logs.

 

Hope that helps!

 

Kind Regards,

PM!

Share this post


Link to post

thank you for trying to help me.

I switched to "MERGE" instead of "COMMAND"

When i set the setDataAdapter to anything else than Prices, Orders ... i get an exception : "Requested Data Adapter, , not found".

I also tried to set Lightstreamer to "154297" , "[154297]", "PRICES.PRICE.154297" and "PRICE.154297", but i still don't receive any Data.

 

you may got any further suggestions ? Just tell me i try it out.

Share this post


Link to post

k, i found the solution we did everything right however to indicate me that i received any data i used

" throw new UnsupportedOperationException("Not supported yet.");"  but for some reason light streamer caught this exception without telling me.

 

I may should have set Lightstreamer to DEBUG logging. How does that work?

Share this post


Link to post
        @Override
        public void onUpdate(int itemPos, String itemName, UpdateInfo update) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void onSnapshotEnd(int itemPos, String itemName) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void onRawUpdatesLost(int itemPos, String itemName, int lostUpdates) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void onUnsubscr(int itemPos, String itemName) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void onUnsubscrAll() {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

that made me believe i didn't receive any data, however exception was caught in lightstreamer thread.

Share this post


Link to post

Hi,

 

I did a search through the Lightstreamer documentation for logging and found the following: http://www.lightstreamer.com/docs/adapter_java_remote_api/com/lightstreamer/adapters/remote/log/Logger.html

 

That may be able to help you figure out how to enable Debug Logging for the Java library. It's probably a good place to start anyway!

 

Kind Regards,

PM!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×