我们正在使用BizTalk Server通过MSMQ发送消息。接收系统要求每个消息都设置扩展属性为GUID(作为字节数组)。MSDN文档了MSMQMessage的Extension属性here和(在.NET中)here。
在.NET中设置扩展属性很简单:
然而,BizTalk的MSMQ适配器并不将消息扩展作为可以设置的内容呈现(请参阅MSDN上适配器属性列表)。我还反编译了随BizTalk 2013一起提供的Microsoft.BizTalk.Adapter.MSMQ.MsmqAdapter程序集,但未找到扩展属性的引用。
如何设置BizTalk发送的MSMQ消息的扩展?如果可能的话,我希望不必创建自定义适配器,因为这需要大量的开销和持续的维护。
在.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程序集,但未找到扩展属性的引用。
如何设置BizTalk发送的MSMQ消息的扩展?如果可能的话,我希望不必创建自定义适配器,因为这需要大量的开销和持续的维护。