如何使用BizTalk的MSMQ适配器设置MSMQ消息扩展名? [英] How do I set the MSMQ Message Extension Using BizTalk's MSMQ Adapter?

查看:101
本文介绍了如何使用BizTalk的MSMQ适配器设置MSMQ消息扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We are using BizTalk Server to send messages via MSMQ. The receiving system requires that each message have the extension property set to a guid (as a byte array). MSDN documents the Extension property of the MSMQMessage here and (in .NET) here.

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

It is simple to set the extension property in .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适配器不会将邮件扩展名显示为可以设置的内容(请参阅 MSDN上的适配器属性列表).我还反编译了BizTalk 2013附带的Microsoft.BizTalk.Adapter.MSMQ.MsmqAdapter程序集,找不到对扩展属性的引用.

However, BizTalk's MSMQ adapter does not surface the message extension as something that can be set (refer to the list of adapter properties on MSDN). I also decompiled the Microsoft.BizTalk.Adapter.MSMQ.MsmqAdapter assembly that ships with BizTalk 2013 and can find no reference to the extension property.

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

How can I set the extension of the MSMQ message sent by BizTalk? I would prefer to not have to create a custom adapter, if possible, as that requires a large amount of overhead and ongoing maintenance.

推荐答案

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

Did you see this article? http://msdn.microsoft.com/en-us/library/aa560725.aspx

本文介绍了如何以编程方式设置MSMQ接收位置;此外,它还提供了对可能是必需的但默认BizTalk适配器未显示的辅助属性的访问权限-(例如,扩展名)

The article shows how to programmatically set an MSMQ receive location; additionally, it exposes access to secondary properties that might be necessary but not shown by the default BizTalk adapter - (e.g. Extension) .

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适配器代码反编译到接口级别之后,我看不到使用默认适配器执行此操作的方法.适配器已密封,也无法扩展.

After decompiling the BizTalk MSMQ adapter code down to the interface level, I don't see a way of doing this using the default adapter. The adapter can't be extended either as it is sealed.

我发现的唯一其他选择是

The only other options I've found are

  1. 创建一个自定义适配器(如您已经列出的那样)
  2. hack 1::将数据放在MSMQ适配器可以访问的属性(例如Label)中,使用外部进程拦截消息,然后在其中进行转换.
  3. hack 2::使用已编写的自定义适配器来调用Powershell脚本,并在该脚本中进行必要的转换/传输. http://social.technet.microsoft.com/wiki/contents/articles/12824.biztalk-server-list-of-custom-adapters.aspx#BizTalk_PowerShell_Adapter
  4. 黑客3:重新定义要求.例如.让接收者将必填字段从扩展名"更改为可用的内容(例如标签").
  5. hack 4::尝试找到一种通过WCF-MSMQ适配器发送消息的方法. http://msdn.microsoft.com/en-us/library /system.servicemodel.netmsmqbinding.aspx
  1. Create a custom adapter (as you have already listed)
  2. hack 1: Place the data in a property that IS accessible by the MSMQ Adapter (e.g. Label), intercept the message with an external process, transform it there.
  3. hack 2: Use a custom adapter that is already written to call a powershell script and do the necessary transformation/transmission in that script. http://social.technet.microsoft.com/wiki/contents/articles/12824.biztalk-server-list-of-custom-adapters.aspx#BizTalk_PowerShell_Adapter
  4. hack 3: Redefine the requirements. E.g. get the receiver to change the required field from Extension to something that is available (e.g. Label).
  5. hack 4: Attempt to find a way to send the message via the WCF-MSMQ adapter. http://msdn.microsoft.com/en-us/library/system.servicemodel.netmsmqbinding.aspx

(您不应该设置扩展属性的原因)

(The reason why you SHOULDN'T set the extension property)

Extension属性用于将大型邮件链接在一起,如果总邮件大小超过4MB,则这些大型邮件在传输中会变得碎片化.这是在后台进行的,如果被规避,则可能导致大邮件的损坏.

The Extension property is used to link large messages together which get fragmented in transport if the total message size is over 4MB. This is done under the covers and if circumvented can cause the corruption of large messages.

要参与大型消息交换,消息队列计算机必须安装Mqrtlarge.dll文件,并且消息队列应用程序应使用附加API.否则,完整的邮件将被分割.

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大邮件扩展文档

BizTalk 2010大消息扩展文档

这篇关于如何使用BizTalk的MSMQ适配器设置MSMQ消息扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆