wcf

配置发布者
发布端最后一部分是WCF配置。如上述所提及的,我们选择使用MSMQ提供可靠的、异步的消息传递。过去编写MSMQ代码比较困难,但是对WCF编程模型而言,MSMQ与其他传输协议没什么区别。在我们的案例中,我们选择了NetMsmqBinding,NetMsmqBinding 为核心MSMQ特性提供了全面访问WCF功能(与MsmqIntegrationBinding不同,MsmqIntegrationBinding提供了更丰富的MSMQ支持,但是限制了WCF功能)。
 
如下是客户端的WCF的配置示例:
<system.serviceModel>

    <
bindings>
        <
netMsmqBinding>
           <
bindingname="TransactionalMsmqBinding"exactlyOnce="true"deadLetterQueue="System" />
        </
netMsmqBinding>
    </
bindings>

    <
client>
        <
endpointname="SubscriberXAccountEventNotification"
            address="net.msmq://localhost/private/SubscriberX/accounteventnotification.svc"
            binding="netMsmqBinding"bindingConfiguration="TransactionalMsmqBinding"
            contract="MyProject.Contracts.IAccountEventNotification" />
    
        <
endpointname="SubscriberYAccountEventNotification"
            address="net.msmq://localhost/private/SubscriberY/accounteventnotification.svc"
            binding="netMsmqBinding"bindingConfiguration="TransactionalMsmqBinding"
            contract="MyProject.Contracts.IAccountEventNotification" />
    </
client>
</
system.serviceModel>
 
上述配置没什么特别的地方 – 需要关注的是 exactlyOnce=”true” 设置,这是事务队列必须的设置。另外就是 net.msmq:// 地址语法,这是NetMsmqBinding 协议所需要的

posted on   隨風.NET  阅读(347)  评论(0编辑  收藏  举报

编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)

导航

< 2011年11月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

统计

点击右上角即可分享
微信分享提示