BizTalk 映射器和 [ThreadStatic] 属性

发布于 2024-08-13 09:56:33 字数 835 浏览 13 评论 0原文

我最近遇到了 BizTalk Mapper 的多线程特性及其处理外部程序集的问题。

正如 MSDN 中的这段引用所示:

重要任何以 外部组件用于 脚本 functoid 需要是线程 安全的。这是必需的,因为 可以使用地图的多个实例 这些 .NET 实例在运行时 压力条件。

映射器将重用外部程序集的实例。

在我的团队使用的实用程序程序集中,我们有以下代码:

public class MapUtil
{
    private string _storeReference;

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

    public string GetStoreReference()
    {
        return _storeReference;
    }
}

这导致一个文件中的存储引用映射到不同的文件。

我(似乎)通过用 [ThreadStatic] 装饰私有字段来解决这个问题。

[ThreadStatic]
private static string _storeReference;

我的问题是 - 有谁知道 BizTalk 映射器中存在任何问题吗?我知道在 Asp.Net 中使用 [ThreadStatic] 会出现问题,因为线程被重用,但找不到有关 BizTalk 映射器处理线程的方式的文档。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾城泪 2024-08-20 09:56:33

我使用 ThreadStatic 将变量设置为自定义接收管道,然后在 BizTalk Map 中访问其值(通过辅助类)。到目前为止还没有遇到任何问题 - 并行测试了约 50 次调用。

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.

む无字情书 2024-08-20 09:56:33

我仍然没有找到类似于“BizTalk Mapper 中的线程行为是 xyz,因此您应该小心使用方法 abc”的明确声明,并且我不确定这样的答案是否会来自任何地方BizTalk 产品团队之外。

我的一位与产品团队有直接联系的同事正在延长圣诞假期(幸运的狗),所以在他回来之前,我只是想我会注意到,随着对代码的更改,我们没有看到线程问题再次出现大批量生产服务器。

嗯 - 这并不完全正确,我设法错过了辅助类上一个属性的 static 关键字,并且对于该属性,我们仍然看到了线程问题。我将以此作为 ThreadStatic 是目前正确方法的证明。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文