A voir, BizTalk rencontre passablement de problèmes pour gérer les fichiers dont le volume est important. Pourtant, malgré les efforts entrepris pour ré architecturer l’application, il est parfois impossible de s’affranchir de ses OutOfMemoryException. Dans le cas du projet actuel, le problème ne se passe que lorsque BizTalk doit traiter plus d’un fichier en même temps. J’ai donc décidé, provisoirement, de ne soumettre à BizTalk qu’un seul fichier à la fois, et attendre qu’il en ait terminé le traitement avant d’en soumettre le suivant. Or, il me semble qu’il n’est pas possible d’être averti lorsqu’une orchestration se termine, dans le framework .NET.
La méthode que j’ai trouvée passe par WMI. Ainsi, pour connaître quand une orchestration se termine :
private void MountBTSOrchestrationMonitoring(){ // Only one watch to mount, because we can only monitor orchestration deletion WqlEventQuery q = new WqlEventQuery(__InstanceDeletionEvent, new TimeSpan(0,0,0,10), "TargetInstance isa \"MSBTS_ServiceInstance\""); m_btsWatcher = new ManagementEventWatcher(new ManagementScope(root/MicrosoftBizTalkServe), q); m_btsWatcher.EventArrived += new EventArrivedEventHandler(bts_OrchestrationDeleted); m_btsWatcher.Start();}private void bts_OrchestrationDeleted(object sender, EventArrivedEventArgs e){ // Do something}
private int OrchestrationInstanceCount(string strOrchestrationName){ System.Text.StringBuilder sb = new System.Text.StringBuilder("SELECT * FROM MSBTS_ServiceInstance WHERE ServiceName=\""); sb.Append(strOrchestrationName); sb.Append("\""); WqlObjectQuery w = new WqlObjectQuery(sb.ToString()); ManagementObjectSearcher objSearcher = new ManagementObjectSearcher(new ManagementScope(kstrWMIBTSNamespace), w); return objSearcher.Get().Count;}
Attention toute fois ! BizTalk met un certain temps avant de mettre en route une orchestration, faisant que même si un fichier est déposé dans un répertoire d’accueil de BizTalk, la méthode risque de renvoyer la valeur 0, car l’orchestration n’aura pas encore démarré. Il serait alors judicieux de voir si des fichiers sont encore présent dans le répertoire d’accueil avant d’en poster de nouveaux.
According to a lot of blogs, BizTalk has some issues with large files. However, despite of the efforts for rearchitecturing the application, it is sometimes not possible to avoid the OutOfMemoryException.
In the case of the actual project, that happens only when BizTalk has to process more than one file at a time. So, I temporary decided to pass to BizTalk only one file at a time and to wait the orchestration stops before copying the next file to the receive location. But, it seems that it is not possible to be warned when an orchestration stops with .NET.
The way I found is using WMI. To know when an orchestration stops, I install an event handler :
If the method returns 0, no orchestration with the given name is still running.
But, warning ! BizTalk needs a bit of time before starting an orchestration and event a file is dropped in a BizTalk receive location, the method will certainly return 0, because the orchestration is not yet started. It would be a good idea to test is there are files in the receive location before dropping new files.
Remember Me
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.