gpt4 book ai didi

msmq - 如何使用 BizTalk 的 MSMQ 适配器设置 MSMQ 消息扩展?

转载 作者:行者123 更新时间:2023-12-04 15:34:52 25 4
gpt4 key购买 nike

我们使用 BizTalk Server 通过 MSMQ 发送消息。接收系统要求每条消息都将扩展属性设置为 guid(作为字节数组)。 MSDN 记录了 MSMQMessage here 的 Extension 属性和(在 .NET 中)here .

在 .NET 中设置扩展属性很简单:

const string messageContent = "Message content goes here";
var encodedMessageContent = new UTF8Encoding().GetBytes(messageContent);

// Create the message and set its properties:
var message = new System.Messaging.Message();
message.BodyStream = new System.IO.MemoryStream(encodedMessageContent);
message.Label = "AwesomeMessageLabel";
// Here is the key part:
message.Extension = System.Guid.NewGuid().ToByteArray();

// Bonus! Send the message to the awesome transactional queue:
const string queueUri = @"FormatName:Direct=OS:localhost\Private$\awesomeness";
using (var transaction = new System.Messaging.MessageQueueTransaction())
{
transaction.Begin();
using (var queue = new System.Messaging.MessageQueue(queueUri))
{
queue.Send(message, transaction);
}
transaction.Commit();
}

但是,BizTalk 的 MSMQ 适配器不会将消息扩展显示为可以设置的内容(请参阅 list of adapter properties on MSDN)。我还反编译了 BizTalk 2013 附带的 Microsoft.BizTalk.Adapter.MSMQ.MsmqAdapter 程序集,并且找不到对扩展属性的引用。

如何设置 BizTalk 发送的 MSMQ 消息的扩展名?如果可能的话,我宁愿不必创建自定义适配器,因为这需要大量开销和持续维护。

最佳答案

你看到这篇文章了吗? http://msdn.microsoft.com/en-us/library/aa560725.aspx

本文展示了如何以编程方式设置 MSMQ 接收位置;此外,它还公开了对可能需要但默认 BizTalk 适配器未显示的辅助属性的访问 - (例如扩展)
.

ManagementClass objReceiveLocationClass =
new ManagementClass(
"root\\MicrosoftBizTalkServer",
"MSBTS_ReceiveLocation",
null);
// Create an instance of the member of the class
ManagementObject objReceiveLocation =
objReceiveLocationClass.CreateInstance();

// Fill in the properties
objReceiveLocation["Name"] = name;
objReceiveLocation["ReceivePortName"] = port;
objReceiveLocation["AdapterName"] = adapterName;
objReceiveLocation["HostName"] = hostName;
objReceiveLocation["PipelineName"] = pipeline;
objReceiveLocation["CustomCfg"] = customCfg;
objReceiveLocation["IsDisabled"] = true;
objReceiveLocation["InBoundTransportURL"] = inboundTransport;

// Put the options -- creates the receive location
objReceiveLocation.Put(options);

编辑:

将 BizTalk MSMQ 适配器代码反编译到接口(interface)级别后,我看不到使用默认适配器执行此操作的方法。适配器也不能扩展,因为它是密封的。

我发现的唯一其他选择是
  • 创建一个自定义适配器(您已经列出)
  • 破解 1:将数据放置在 MSMQ 适配器可访问的属性中(例如标签),使用外部进程拦截消息,然后在此处进行转换。
  • 技巧 2:使用已经编写好的自定义适配器调用 powershell 脚本并在该脚本中进行必要的转换/传输。 http://social.technet.microsoft.com/wiki/contents/articles/12824.biztalk-server-list-of-custom-adapters.aspx#BizTalk_PowerShell_Adapter
  • 技巧 3:重新定义需求。例如。让接收者将必填字段从扩展更改为可用的内容(例如标签)。
  • 技巧 4:尝试找到一种通过 WCF-MSMQ 适配器发送消息的方法。 http://msdn.microsoft.com/en-us/library/system.servicemodel.netmsmqbinding.aspx

  • 编辑:
    (你不应该设置扩展属性的原因)

    Extension 属性用于将大型消息链接在一起,如果总消息大小超过 4MB,则这些消息会在传输中分散。这是在幕后完成的,如果绕过可能会导致大型消息的损坏。

    To participate in large message exchanges, the message queuing computer must have the Mqrtlarge.dll file installed, and the message queuing application should use the add-on APIs. Otherwise, complete messages will be fragmented.



    BizTalk 2004 Large Message Extension Documentation

    BizTalk 2010 Large Message Extension Documentation

    关于msmq - 如何使用 BizTalk 的 MSMQ 适配器设置 MSMQ 消息扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18725319/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com