Thank you!
Luca Dominici
Posts
-
WCF / Single instance / multple concurrency question -
WCF / Single instance / multple concurrency questionThank you for your reply. My configuration is your second one: 1 WCF service for 9 Clients. There is not much server logic in the WCF, but since is a generic Barcode generator placed in a context where a lot of applications could use it, I think that is a good choice to have it in WCF instead of inside the main project. I will do some benchmatks to understand better if it is an issue or not. However, my question regards how to use (and consume) wcf: I have to declare simply:
public static BarcodeServiceClient BarcodeServiceClient
{
get
{
if (_barcodeServiceClient == null)
{
_barcodeServiceClient = new BarcodeServiceClient();
}
return _barcodeServiceClient;
}
}OR I have to manage channels?
-
WCF / Single instance / multple concurrency questionHi, I am new to WCF, but I like to have them in my production project instead of web services because of greater flexibiltity of WCF. I have this scenario: One WCF that serve 9 client of the same application (on 9 different servers). The WCF build a Barcode ad return a PNG image. I think that the better configuration is Single instance / Multiple concurrency. I also use Async methods to reduce latency. Note that the client instance is a singleton shared between users on the same server, maybe a check on channel status is necessary? Actually I am a little confused reading articles on WCF: some don't talk about Channel state, factory etc. Others articles show checks on channel state and Channel factory everywhere... What I have to do to make this thing work? Thank you! NOTE: using framework 3.5
-
strange issue with cache application block (ENT LIB 5)Hi all, I am relatively new to Caching application block, so my problem can be very trivial. But I don't get it. So there is this complex application (in production enviroment) that I have rewritten to use cache. my framework is not so easy to describe, however: every service class (in the logic tier) has a father class that define the cache (static, so application wide)
SmallObjectCache = EnterpriseLibraryContainer.Current.GetInstance<ICacheManager>("SmallObjectCache");
I have written some classes to manage my cache: I use for single objects and for list of object (Read operation and GetAll operation)
protected virtual void CacheAddData(DomainObject domainObject)
{
if (domainObject != null)
{
CacheDictionary[this.GetType().FullName].Add(this.GetType().FullName + "_" + domainObject.GetId(), domainObject);List<DomainObject> cachedObj = CacheGetAllData(); if (cachedObj != null && cachedObj.Count > 0) { int idx = -1; try { idx = cachedObj.FindIndex(a => a.GetId() == domainObject.GetId()); cachedObj.RemoveAll(a => a.GetId() == domainObject.GetId()); } catch (NullReferenceException) { BusinessFacade.ApplicationLogger.Write("INFO: Cache: Linq exception", Category.General, Priority.Normal, 1, System.Diagnostics.TraceEventType.Information); } if (idx >= 0) cachedObj.Insert(idx, domainObject); else cachedObj.Add(domainObject); CacheAddAllData(cachedObj); } }
}
So what the above do is to add an item in cache and if exist a list of that objects retrive it and add/insert in the right position the item. Now the bug: Everything is running fine. 100+ people use the system without a glitch. BUT sometime, near middle of the day, one or two people report a nullreference exception, especially in this code:
List<Utente> decoratori = GetAll().Cast<Utente>().ToList().Where<Utente>(u => u.Ruolo.IsDecoratore()).ToList();
the where iterator crash stating that object is null (I do checks before the only null objects can be the "Ruolo") Now this is the issue: the same user with everyting unchanged became without an attribute (non deterministic). Recycling the IIS memory fix the issue (so is not a reproducible issue).