惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
博客园 - Franky
J
Java Code Geeks
V
Visual Studio Blog
G
Google Developers Blog
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
博客园 - 【当耐特】
IT之家
IT之家
I
InfoQ
U
Unit 42
C
Check Point Blog
Martin Fowler
Martin Fowler

博客园 - 成都ABC

json 反序列化,高手请进 Django Message框架尝鲜 MVC 资料推荐 杂类 资料收集 收集到的非常好的第三方控件 Silverlight 开源框架 微软企业库资料 Silverlight 收藏网站 Silverlight的依赖属性与附加属性 对MVP和MVVM的一点看法 使用BizTalk Server常见问题处理 在哪找biztalk的例子(转) 转:把自己搜集到的一些silverlight网站、第三方控件及开源代码与大家们分享(微软转载) 鸡肋: 评在IE下Siverlight3对快捷键的支持 siverlight高手解答:无法阻止silverlight把快捷键传递给IE7 WCF综合运用之:聊天系统 微软:PHP在IIS 7上雄起 - 成都ABC - 博客园 WCF学习之:实例上下文模式和并发模式的性能影响
不需要Orchestration,通过Pipeline设定动态发送端口属性
成都ABC · 2010-03-08 · via 博客园 - 成都ABC

不需要Orchestration,通过Pipeline设定动态发送端口属性

通常情况下使用动态发送端口,需要Orchestration中使用表达式(Expression)指定具体的发送端口目的地址Port_1(Microsoft.XLANGs.BaseTypes.Address) = http://www.tradingpartner.com/receive.ashx     具体的地址可以根据传入的Message通过xpath表达式或是Promote属性获取,但是每个流程只能接收制定的Schema消息,如果想做一个通用的根据消息路由就不是很方便了。

实际情况是这样,有100 不同的Schema,需要根据具体的消息实例的内容进行路由,具体的地址存放在“路由表”中,可以动态维护,一开始通过OrchestrationReciveMessage的类型定义为通用的XmlDocument处理,在流程中通过xpath获取值后再去找“路由表”中对应的地址,设定动态发送端口地址。

这样做很显然效率很差,而且不规范,容易冲突

现在可以直接通过自定义开发receivepipeline组件,在pipeline执行时把需要的地址通过属性升级(promote)方式赋值,这样动态发送端口就可以直接根据具体属性值进行发送到指定的目的地。

注意:动态发送端口只能订阅到具有promote OutboundTransportType 和OutboundTransportLocation 属性的消息,如果以上两个属性没有升级,只是通过ReceivePortName或其他属性是无法订阅到消息的。

代码:

IBaseMessageContext context = inmsg.Context;

            IBaseMessagePart bodyPart = inmsg.BodyPart;

            Stream originalStrm = bodyPart.GetOriginalDataStream();

            string inval = string.Empty;

            string outboundaddress = string.Empty;

            string[] fixstr;

            inval = Convert.ToString(context.Read(this._PropName, this._PropNamespaces));

            if (string.IsNullOrEmpty(inval))

            {

                //inval = GetInMessageValue(originalStrm);

            }

            //outboundaddress = this.GetTransportLocation(inval);

            outboundaddress = @"msmq://.\private$\mq1";

            if (outboundaddress.IndexOf("://") > 0)

            {

                fixstr = outboundaddress.Split(':');

                this._PropTransportType = fixstr[0];

                int firstidx = outboundaddress.IndexOf("//");

                outboundaddress = outboundaddress.Substring(firstidx + 2);

            }

            if (this._PropTransportType.ToLower().Trim() == "msmq")

            {

                context.Promote("Transactional", "http://schemas.microsoft.com/BizTalk/2003/msmq-properties", this._PropTransactional);

                context.Promote("TimeOut", "http://schemas.microsoft.com/BizTalk/2003/msmq-properties", 4);

                context.Promote("TimeOutUnits", "http://schemas.microsoft.com/BizTalk/2003/msmq-properties", "Days");

            }

            context.Promote("OutboundTransportType", "http://schemas.microsoft.com/BizTalk/2003/system-properties", this._PropTransportType);

            context.Promote("OutboundTransportLocation", "http://schemas.microsoft.com/BizTalk/2003/system-properties", outboundaddress);

            if (!string.IsNullOrEmpty(this._PropSPID.Trim()))

                context.Promote("SPID", "http://schemas.microsoft.com/BizTalk/2003/system-properties", this._PropSPID);

              bodyPart.Data = originalStrm;

            pc.ResourceTracker.AddResource(originalStrm);

            return inmsg;

这样做自然性能会提高很多,方便维护