Print Page | Close Window

Push Notifications method start twice on 2 differents threads

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3612
Printed Date: 13-May-2026 at 1:03am


Topic: Push Notifications method start twice on 2 differents threads
Posted By: Walid
Subject: Push Notifications method start twice on 2 differents threads
Date Posted: 06-Sep-2012 at 10:31am
Hi,

I am not sure to understand how to use the push notification with Devforce.
Here is what I can read on the documentation : "A push service is started upon the first client subscription.  Once started, the service can run indefinitely and support any number of subscribing clients.  The service runs on its own thread and can perform any processing desired, including starting additional threads or processes"

So if I have 2 ViewModel which both want to register to this service, the first call to RegisterCallback will start the method and the second call will add the new subscriber to the subscribers collection.

Here is what I have in my logs  :

2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:.ctor NotificationServiceManager started 
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:.ctor NotificationServiceManager started 
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:RegisterUser New user registered for NewDossiers 
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:RegisterUser New user registered for NewDossiers 
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationThreadHelper:RunServerMethod NewDossiers is starting on thread 22 
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationThreadHelper:RunServerMethod NewDossiers is starting on thread 4 
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor:ExecuteQuery Fetch ... value(IdeaBlade.EntityModel.EntityQueryProxy`1[Domain.Entities.Dossier]).Where(dos => (dos.CreationDate >= 06/09/2012 18:27:03)) 

We can see the method NewDossiers was started twice on 2 differents thread. Unfortunatly, this cause an exception when I try to query the EntityManager because it is now on the wrong thread.

In both viewmodel, I call the method RegisterCallback with the same parameters except the Usertoken, each VM has his own. This bring me to a question about the usertoken. Is it the way to use the token ?
In the API documentation, you write : "The userToken should be used to identify the client request. It does not have to be unique acrosss all clients, but it must be unique for all requests from a single client"
I am about confuse about the notion of client here. is a ViewModel a client or are you talking about the silverlight application itself ? if I try to register both with the same token it thrown an exception so the sentence confuse me.

So, Is this normal or a bug to see this method on thread 22 then 4 ?
If it is normal, how should I handle such scenario ?

Note : 
It doesn't happen all the time, sometimes it start on one thread only.
In my case, both viewmodel register to the service in the same time (they both listen to the same event in my application and once it is raise they call RegisterCallback). 





Replies:
Posted By: DenisK
Date Posted: 06-Sep-2012 at 6:19pm
Hi Walid,

I can see the issue here and it seems to be a bug or some sort of threading issue. 

Whenever you call RegisterCallback with a different userToken, that will constitute a new client/subscriber.

I'm still doing more investigation and I'll update you as soon as I have something.




Posted By: DenisK
Date Posted: 07-Sep-2012 at 12:33pm
Hi Walid,

It seems that there's a race condition related to threading here that's causing a push service to spawn a new thread. This is why you don't always see it.

I've opened a bug report.

We don't currently have a workaround for this. Perhaps we can give some suggestions if you can share your use case.


Posted By: Walid
Date Posted: 20-Sep-2012 at 2:23pm
Hi,

I see in the Devforce 7.0 release notes that the Notification service has been removed (aka no more push).

Will you propose something equivalent in a near future ?? that is a pretty bad surprise  ... :(

Regards,


Posted By: kimj
Date Posted: 20-Sep-2012 at 4:20pm
Hi Walid,
 
Push was removed from the DevForce 2012 Beta release because in truth it seems more trouble than it's worth:  it's the source of many bugs, such as the one you reported above.  The feature is also somewhat out-of-band from the persistence features of DevForce.   At this time we don't have an equivalent feature planned, but we may resurrect Push in the RTW release if there's enough interest.
 
Can you tell us a little about your use case and why you chose to use Push in DevForce?


Posted By: GeorgeB
Date Posted: 21-Sep-2012 at 2:13am
Hi Kim
 
I make extensive use of Push in DF 2010 in a large SL5 application.
 
We have users all over the country and when someone in one city adds or updates certain tables, we have inform other users so that they can react on those changes,
 
Removing Push from DF 2012 is quite extreme.
 
We'll need to know early if Push isn't going to make RTM as we have a new version going live the end of October and I would like to use DF 2012 as soon as possible.
 
Kr
George


Posted By: Walid
Date Posted: 21-Sep-2012 at 8:08am
I have the exact same kind of scenario as GerorgeB.

Sometimes the changes comes from the server itself. I have a case where a service on the server is looking for the presence of a file in a specific folder. When it is there, it creates data in the database regarding of the content of the file.
I then need to advertise the presence of new datas to a specific category of users

I really hope to see the push in the RTM version !

regards



Posted By: kimj
Date Posted: 21-Sep-2012 at 8:12am
Thanks for the feedback, George.  With you and Walid that make 2 requests on the first day of release, so it does seem there's more interest and use of Push than we realized.  Keep an eye on the "Community Feedback" section of the DF2012 forum - we'll announce any changes there. 


Posted By: mgood
Date Posted: 21-Sep-2012 at 1:28pm
Walid and George,
Push was never DevForce's strong suit. Take a look at SignalR ( https://github.com/SignalR/SignalR/wiki - https://github.com/SignalR/SignalR/wiki ). 



Print Page | Close Window