Could you add a very simple log to file in your adapters? Just to understand what is going on.
Could you add a very simple log to file in your adapters? Just to understand what is going on.
Hello,
Finally find out the issue, I have modified my shell script as like below,
It seems need to give values within double quote.cpath="/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/ls-adapter-remote.jar:/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/jedis.jar:/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/gson.jar:/home/postnammauzhavan/Lightstreamer/adapters/WINLITERemoteStockList/classes/LS_quote_feed_simulator.jar"
class="stocklist.server.ServerMain"
command="java -cp $cpath $class -host localhost -metadata_rrport 6722 -data_rrport 6720 -data_notifport 6721"
exec $command $
Now I have an issue on getting update from redis and serve this data to subscribed items.
I have used redis instance on ExternalFeedSimulator java class. Can you please on this where I need to create instance and where to close the redis exactly. Because of this I'm facing the issue like
Exception in thread "Timer-0" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 12In my php service every second will update the stock market rates into redis key as json string. In my java adapter for every 500 milliseconds i need to read and update to subscribed clients. Could you please help me on this how to do this in my adapter.My code looks like below,
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import redis.clients.jedis.Jedis;
public class ExternalFeedSimulator {
private static Jedis jedis;
private static final String redisHost = "localhost";
private static final Integer redisPort = 6379;
private static Gson gson = new Gson();
public void start() {
try {
jedis = new Jedis(redisHost, redisPort);
getJSON();
long waitTime = 500;
bidaskratescheduleGenerator(bidaskrates, waitTime);
} catch (Exception e) { System.out.println(e);
}
}
public static String getJSON() {
try {
liveratesnew.clear(); ClientsRateRow[] craterows = gson.fromJson(jedis.get("WLallclientsrates"), ClientsRateRow[].class);
for (ClientsRateRow raterow : craterows) {
liveratesnew.put(raterow.client_com_id, raterow);
curclientrates.add(raterow);
}
RateRow[] cbaserates = gson.fromJson(jedis.get("WLBaseRates"), RateRow[].class);
for (RateRow raterow : cbaserates) {
bidaskrates.add(raterow);
}
} catch (IllegalStateException ex) {
ex.printStackTrace();
} finally {
jedis.close();
}
return null;
}
private void bidaskratescheduleGenerator(final ArrayList<RateRow> displayrates, long waitTime) {
dispatcher.schedule(new TimerTask() {
@Override
public void run() {
long nextWaitTime;
synchronized (displayrates) {
if (listener != null) {
for (RateRow curbidaskrates : displayrates) {
final HashMap<String, String> bidaskevent = new HashMap<String, String>();
bidaskevent.put("desc", curbidaskrates.getGold1_symbol());
bidaskevent.put("bid", curbidaskrates.getGold1_bid());
bidaskevent.put("ask", curbidaskrates.getGold1_ask());
bidaskevent.put("high", curbidaskrates.getGold1_high());
bidaskevent.put("low", curbidaskrates.getGold1_low());
bidaskevent.put("ltp", curbidaskrates.getGold1_ltp());
listener.onEvent(curbidaskrates.getGold1_symbol(), bidaskevent, false);
}
}
displayrates.clear();
nextWaitTime = 500;
}
getJSON();
bidaskratescheduleGenerator(bidaskrates, nextWaitTime);
}
}, waitTime);
}
}
Last edited by rvkvino; July 8th, 2020 at 07:49 AM.
Hi,
The error message seems not pertaining to redis but to the json parser.
Please have a look at this https://stackoverflow.com/questions/...ine-1-column-1, maybe can help with your issue.
Regards,
Giuseppe
I have referred this link already,
My actual issue comes like this first time after that only I'm facing issue on json string. If I handle this issue the above json issue not comes.
my json looks like this onlyredis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Connection reset by peer: socket write error
at redis.clients.jedis.Connection.flush(Connection.java:334)
at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:257)
at redis.clients.jedis.Connection.getBulkReply(Connection.java:248)
at redis.clients.jedis.Jedis.get(Jedis.java:153)
at stocklist.feed_simulator.ExternalFeedSimulator.getJSON(ExternalFeedSimulator.java:78)
at stocklist.feed_simulator.ExternalFeedSimulator$1.run(ExternalFeedSimulator.java:128)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at redis.clients.util.RedisOutputStream.flushBuffer(RedisOutputStream.java:52)
at redis.clients.util.RedisOutputStream.flush(RedisOutputStream.java:216)
at redis.clients.jedis.Connection.flush(Connection.java:331)
.
This above json i'm parsing using the class,(Array of object)[
{
"com_id": "33",
"com_name": "GOLD BAR",
"selling_rate": "5001",
"buying_rate": "-",
"delivery": "03-07-2020",
"retail_rate": "-",
"com_weight": "1.000",
"com_order": "1",
"client": "lmxtrade",
"client_com_id": "lmxtrade_33",
"high_rate": "5002",
"low_rate": "4980"
},
{
"com_id": "36",
"com_name": "GOLD FT",
"selling_rate": "5001",
"buying_rate": "4800",
"delivery": "03-07-2020",
"retail_rate": "-",
"com_weight": "1.000",
"com_order": "2",
"client": "lmxtrade",
"client_com_id": "lmxtrade_36",
"high_rate": "5002",
"low_rate": "4980"
},
{
"com_id": "37",
"com_name": "GOLD RTGS",
"selling_rate": "4901",
"buying_rate": "-",
"delivery": "03-07-2020",
"retail_rate": "-",
"com_weight": "1.000",
"com_order": "3",
"client": "lmxtrade",
"client_com_id": "lmxtrade_37",
"high_rate": "4902",
"low_rate": "4880"
},
{
"com_id": "38",
"com_name": "SILVER",
"selling_rate": "49190",
"buying_rate": "48463",
"delivery": "03-07-2020",
"retail_rate": "-",
"com_weight": "1000.000",
"com_order": "4",
"client": "lmxtrade",
"client_com_id": "lmxtrade_38",
"high_rate": "49190",
"low_rate": "49190"
},
{
"com_id": "33",
"com_name": "GOLD CBE RTGS ",
"selling_rate": "5001",
"buying_rate": "4890",
"delivery": "07-07-2020",
"retail_rate": "-",
"com_weight": "1.000",
"com_order": "1",
"client": "kkvtrade",
"client_com_id": "kkvtrade_33",
"high_rate": "5002",
"low_rate": "4980"
},
{
"com_id": "36",
"com_name": "GOLD FT",
"selling_rate": "5001",
"buying_rate": "4900",
"delivery": "07-07-2020",
"retail_rate": "-",
"com_weight": "1.000",
"com_order": "2",
"client": "kkvtrade",
"client_com_id": "kkvtrade_36",
"high_rate": "5002",
"low_rate": "4980"
},
{
"com_id": "37",
"com_name": "GOLD RTGS",
"selling_rate": "4901",
"buying_rate": "5000",
"delivery": "07-07-2020",
"retail_rate": "-",
"com_weight": "1.000",
"com_order": "3",
"client": "kkvtrade",
"client_com_id": "kkvtrade_37",
"high_rate": "4902",
"low_rate": "4880"
},
{
"com_id": "38",
"com_name": "SILVER",
"selling_rate": "50369",
"buying_rate": "50354",
"delivery": "07-07-2020",
"retail_rate": "-",
"com_weight": "1000.000",
"com_order": "4",
"client": "kkvtrade",
"client_com_id": "kkvtrade_38",
"high_rate": "50400",
"low_rate": "50008"
}
]
ClientsRateRow[] craterows = gson.fromJson(jedis.get("WLallclientsrates"), ClientsRateRow[].class);
Last edited by rvkvino; July 8th, 2020 at 09:32 AM.
Have you tried to approach all redis operations in the getJSON method (open the connection, retrieve the json and close)?
Yes this helped me. I have open and close all the places wherever I have used Redis and then closed. Now working fine my adapter. My problem is solved in website. Now I need to know whether is there any LS client library is available for dart language. I'm developing app in Flutter, now I need to show market rates in app also which I done in website.
Bookmarks