BizTalk SendPort 过滤器可以根据消息内容过滤出要发送的目标。 在 BizTalk 中,您可以使用 BTS.MessageType 属性过滤出消息类型,或使用使用 BizTalk 转换器创建的自定义属性来过滤消息。以下是一些使用 C# 代码创建 BizTalk SendPort 过滤器的示例:
使用 BTS.MessageType 属性过滤消息类型:
using Microsoft.BizTalk.Message.Interop;
// 获取 BTS.MessageType 属性
var messageType = messageContext.Read("http://schemas.microsoft.com/BizTalk/2003/system-properties#MessageType", "http://schemas.microsoft.com/BizTalk/2003/system-properties");
if (messageType.Equals("urn:schemas.microsoft.com:BizTalk/EDI/X12#810"))
{
return true;
}
else
{
return false;
}
使用自定义属性过滤消息:
using Microsoft.BizTalk.Message.Interop;
// 获取自定义属性
var myProperty = messageContext.Read("http://schemas.example.com#MyProperty", "http://schemas.example.com");
if (myProperty.Equals("MyValue"))
{
return true;
}
else
{
return false;
}