kishorekkk
Hi All,
I am not getting what is the problem in my code. in my html page i am using 42 items, i written one adapter class using Java API, i used SmartDataProvider.
i am not getting any errors in server console, i used ItemEventListener ,
smartUpdate(handle,inactiveMap,false) method, this method is also working fine. the server console is showing the System.out.println() line which added with completeInactiveMap details. but front end html page is not updating with new data.
adapter.xml file
<adapters_conf id="GROUPLIVERATES33">
<metadata_provider>
<adapter_class>com.lightstreamer.adapters.metadata.LiteralBasedProvider</adapter_class>
</metadata_provider>
<data_provider>
<adapter_class>com.group.adapter.GroupStreamAdapter</adapter_class>
</data_provider>
</adapters_conf>
The code for page
<script type="text/javascript">
for (var i = 0; i <42; i++) {
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="Symbol">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="ABC">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="OfferVol">-</div></td>');
document.write('<td><span source="lightstreamer" table="main2" item="i'+i+'" field="OfferPrice">-</span></td>');
document.write('<td nowrap><div source="lightstreamer" table="main2" item="i'+i+'" field="BidVolume">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="BidPrice">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="Volume">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="High">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="Low">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="LastPrice">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="PrevClose">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="Chg">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="%">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="Trades">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="OpenPrice">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="AvgPrice">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="High52Week">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="Low52Week">-</div></td>');
document.write('<td><div source="lightstreamer" table="main2" item="i'+i+'" field="Value">-</div></td>');
document.write('</tr>');
}
</script>
var page = new PushPage();
page.onEngineCreation = function(engine) {
engine.connection.setAdapterName("GROUPLIVERATES33");
engine.connection.setLSHost("localhost");
engine.connection.setLSPort("9911");
engine.changeStatus("STREAMING");
}
page.bind();
page.createEngine("GROUPLIVERATES33APP", "LS", "SHARE_SESSION");
var pushtable = new OverwriteTable(null, null, "MERGE");
page.addTable(pushtable, "main2");
the Java adapter is :
public class GroupStreamAdapter implements SmartDataProvider , EMSMessageListener{
public ItemEventListener listener;
private ConcurrentHashMap<String,SubscribedItemAttributes> subscribedItems = new ConcurrentHashMap<String,SubscribedItemAttributes>();
private ConcurrentHashMap<String,Object> handles = new ConcurrentHashMap<String,Object>();
private volatile int nextHandleId =0;
private static HashMap<String,String> inactiveMap = new HashMap<String,String>();
private static HashMap<String,String> completeInactiveMap = new HashMap<String,String>();
static {
inactiveMap.put("item_status","inactive");
completeInactiveMap.put("Symbol", "Test");
completeInactiveMap.put("ABC", "+");
completeInactiveMap.put("OfferVol","0");
completeInactiveMap.put("OfferPrice", "0");
completeInactiveMap.put("BidVolume", "0");
completeInactiveMap.put("BidPrice", "0");
completeInactiveMap.put("Volume", "0");
completeInactiveMap.put("High", "0");
completeInactiveMap.put("Low", "0");
completeInactiveMap.put("LastPrice", "0");
completeInactiveMap.put("Chg", "0");
completeInactiveMap.put("%", "0");
completeInactiveMap.put("Trades", "0");
completeInactiveMap.put("OpenPrice", "0");
completeInactiveMap.put("AvgPrice", "0");
completeInactiveMap.put("High52Week", "0");
completeInactiveMap.put("Low52Week", "0");
completeInactiveMap.put("Value", "0");
} // static
public void subscribe(String itemName, Object itemHandle, boolean needsIterator)throws SubscriptionException, FailureException {
System.out.println("GroupAdapter - subscribe(...) "+itemName);
String uniqueId = String.valueOf(nextHandleId++);
SubscribedItemAttributes itemAttrs = new SubscribedItemAttributes(itemName,uniqueId);
rwLock.writeLock().lock();
subscribedItems.put(itemName, itemAttrs);
handles.put(uniqueId,itemHandle);
listener.smartUpdate(handle,completeInactiveMap,false);
System.out.println("========"+completeInactiveMap);
}
Dario Crivelli
I can't find typos at first sight.
I see that smartUpdate uses a "handle" argument which is not defined, but I suppose that your code snippet is just a compound.
Does your Data Adapter send only one update for each item and does it return "true" from "isSnapshotAvailable"? (But I'm not sure that this could explain the behavior).
To simplify the analysis, please get a detailed log from the Server, after setting the priorities for the "LightstreamerLogger.subscriptions" and "LightstreamerLogger.pump" categories as DEBUG in the Server log configuration file.