-
August 21st, 2008, 10:04 PM
#1
<Also note that synchronization issues may need to be considered.
And that I think I am having a problem with. I am running a process that stupidely sends current time with an interval of one second to push to the cient. I see that sometimes (not that bad though) I am missing some data. What would you suggest?
Thanks
-
August 22nd, 2008, 12:13 PM
#2
I warned about synchronization issues with relation to my suggestion of putting a pointer to the Data Adapter on a static variable. I did it just in case.
If you, after revising your code, can now see that some updates do reach the client, I cant' figure how synchronization problems could cause single updates to be lost.
It is possible that some events are merged by the Server, if bandwidth or frequency restrictions are configured.
You can check the event flow through the Server in the Server log, after setting the priority for the "LightstreamerLogger.subscriptions" and "LightstreamerLogger.pump" categories to DEBUG in "lightstreamer_log_conf.xml".
-
August 22nd, 2008, 01:39 PM
#3
Here is my latest code with which I am missing some data sometimes:
using System.Collections;
using System.Threading;
using System;
using System.Runtime.InteropServices;
using Lightstreamer.Interfaces.Data;
using System.Windows.Forms;
public class SocketToLightStreamer : IDataProvider
{
private IItemEventListener _listener;
public void Init(IDictionary parameters, string configFile)
{
}
public bool IsSnapshotAvailable(string itemName)
{
return false;
}
public void SetListener(IItemEventListener eventListener)
{
_listener = eventListener;
}
public void Subscribe(string itemName)
{
if (itemName.Equals("floorupdate"))
{
Form f = new GetMessage(this);
f.Show();
f.Hide();
ApplicationContext ctx = new ApplicationContext();
Application.Run(ctx);
}
}
public void Unsubscribe(string itemName)
{
if (itemName.Equals("floorupdate"))
{
}
}
public void PushData(string data)
{
System.Console.WriteLine(data);
IDictionary eventData = new Hashtable();
eventData["scan"] = data;
_listener.Update("floorupdate", eventData, false);
}
public class GetMessage : Form
{
const int WM_COPYDATA = 0x004a;
private SocketToLightStreamer clientUpdater;
public GetMessage(SocketToLightStreamer o)
{
Text = "my_unique_id";
clientUpdater = o;
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_COPYDATA:
COPYDATASTRUCT mystr = new COPYDATASTRUCT();
Type mytype = mystr.GetType();
mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
new Thread(delegate() { clientUpdater.PushData(mystr.Data); }).Start();
break;
}
base.WndProc(ref m);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public Int32 ID;
public int Length;
public string Data;
}
}
I see missing data in the Console written in PushData method.
Here is sample of data being lost:
22-Aug-08 08:19:41,266 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Pumping event in session Sa4839d7557b06b92T1742762: d(1,1,1,"08:19:40^text2\u000D");
22-Aug-08 08:19:42,266 |TRACE|LightstreamerLogger.subscriptions|#1 Notify Receiver |INCOMING DATA for floorupdate --> {scan=08:19:41^text1
}
22-Aug-08 08:19:42,266 |DEBUG|LightstreamerLogger.subscriptions|#1 Notify Receiver |Manager: com.lightstreamer.e.s@8046f4
22-Aug-08 08:19:42,266 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Pumping event in session Sa4839d7557b06b92T1742762: d(1,1,1,"08:19:41^text1\u000D");
22-Aug-08 08:19:43,376 |TRACE|LightstreamerLogger.subscriptions|#1 Notify Receiver |INCOMING DATA for floorupdate --> {scan=08:19:43^text2
}
-
August 25th, 2008, 09:58 AM
#4
If I understand well, you are complaining about the absence of an event for 08:19:42.
The log shows that such event is missing in the flow from the Data Adapter, hence it is not filtered because of bandwidth or frequency restrictions.
However, I cannot find any evidence in the Data Adapter code that an event for 08:19:42 was supposed to be generated, as it seems that part of the event production process takes place externally. Moreover, I notice that the last "INCOMING DATA" event in the log file happens significantly more than one second after the preceding one.
So, the Remote Data Adapter part is now to be logged.
If you find it useful, you can enable logging by Lightstreamer libraries on the Remote Server, by configuring a <log4net> session in a way similar to the
DOCS-SDKs\sdk_adapter_dotnet\examples\DotNetStockListDe mo\Deployment\Deployment_DotNet_Server\dotnet_1.1\ DotNetServer.exe.config
file. Just set DEBUG level for the Lightstreamer.DotNet.Server.RequestReply logger to have the Update calls logged.
Just in case, note that the field values of your events (like "08:19:41^text1\u000D", the trailing being a return character) seem to lack some processing.
-
August 25th, 2008, 04:33 PM
#5
I am going to follow your recomdations but I think the reason for missing data is that sometimes data push by the LS takes just a moment longer (means resources are still busy) and my data adapter does not have a chance to process, hence it does not provide avery data for to LS for data push. That was the reason to have actual code for data push into another thread. It seamed helped but not for 100%.
What do you think about that?
BTW, My data is just a test data, but missings also happen with the real data that does not have a "^" symbol.
Thanks for your help.
-
August 26th, 2008, 09:06 AM
#6
I see you avoid to invoke _listener.Update from a critical thread (as the one running WndProc seems to be).
However, the Update call implementation also enqueues the values, so that they are processed by another thread, provided by Lightstreamer library.
Hence, we don't advise you against calling Update from a critical thread, as we don't expect Update to be blocking.
Moreover, with so few updates, CPU overload problems are also not possible.
So, I can't understand where your Data Adapter process may be blocked.
Can you get any evidence that Lightstreamer is involved? If you comment out the Update call and just log the updates, can you see a different behaviour?
-
August 26th, 2008, 01:06 PM
#7
Yes, I did comment out the update call. I still had lost data, I would say less then with updates but still there was lost data. Knowing my code would you recommend anything to preotect from losing data?
Thanks
Similar Threads
-
By mode_vigilante in forum Adapter SDKs
Replies: 16
Last Post: January 27th, 2012, 03:58 PM
-
By icaiozzi in forum Adapter SDKs
Replies: 1
Last Post: November 19th, 2010, 11:52 AM
-
By AndyKelly in forum Client SDKs
Replies: 1
Last Post: July 7th, 2010, 10:50 AM
-
By devidasan in forum Adapter SDKs
Replies: 1
Last Post: March 17th, 2009, 11:00 AM
-
By markgoldin in forum General
Replies: 6
Last Post: September 28th, 2007, 01:15 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 02:36 PM.
Bookmarks