English 中文(简体)
BizTalk mapper and the [ThreadStatic] attribute
原标题:

I ve recently encountered an issue with the multi-threaded nature of the BizTalk Mapper and how it handles external assemblies.

As this quote from MSDN indicates:

Important Any code written in an external assembly for use in a scripting functoid needs to be thread safe. This is required because multiple instances of a map can use these .NET instances at run time under stress conditions.

The Mapper will reuse instances of external assemblies.

In a utility assembly my team was using we had the following code:

public class MapUtil
{
    private string _storeReference;

    public void SetStoreReference(string ref)
    {
       _storeReference = ref;
    }

    public string GetStoreReference()
    {
        return _storeReference;
    }
}

This was causing storereferences from one file to be mapped to different files.

I (appear) to have fixed this by decorating the private field with [ThreadStatic]

[ThreadStatic]
private static string _storeReference;

My question is - does anyone know of any issues with this in the BizTalk Mapper? I m aware that there are issues using [ThreadStatic] in Asp.Net for examble, due to threads being reused, but can find no documentation on the way the BizTalk mapper deals with threads.

最佳回答

I ve still not found a definitive statement along the lines of The threading behaviour within the BizTalk Mapper is xyz, so you should take care you use method abc and I m not sure that such an answer is going to come from anywhere outside the BizTalk product team.

My one colleague with direct contacts to the product team is on extended Christmas leave (lucky dog) so until he returns I just thought I d note that with the change made to our code we have not seen a single recurrence of the threading issues on a high volume production server.

Well - that isn t quite true, I managed to miss the static keyword from one property on my helper class and for that property we did still see the threading issues. I ll take that as proof of ThreadStatic being the right way to go for now.

问题回答

I have used ThreadStatic to set a variable is custom receive pipeline and then access its value within BizTalk Map (through a helper class). have not got any problem so far - tested with ~50 invocations in parallel.





相关问题
BizTalk server problem

we have a biztalk server (a virtual one (1!)...) at our company, and an sql server where the data is being kept. Now we have a lot of data traffic. I m talking about hundred of thousands. So I m ...

Create key pair for BizTalk AS2 connection

I need to create an AS2 connection in BizTalk Server 2006 R2 to communicate with a business partner. I ve worked with BizTalk AS2 config before and the BizTalk docs have pretty good walkthroughs about ...

BizTalk mapper and the [ThreadStatic] attribute

I ve recently encountered an issue with the multi-threaded nature of the BizTalk Mapper and how it handles external assemblies. As this quote from MSDN indicates: Important Any code written in an ...

女士们:

我正在分析一项BizTalk(ka orchestration)申请,该申请正在由MSMQ与一个WCF服务机构进行沟通。 我不禁要问,为什么世界气候基金的一个服务执行项目有一个小参数。

热门标签