WCF服务编程设计规范(6):队列服务、安全和服务总线。本节整理队列服务(Queue Servuce)、服务安全(Service Security)和服务总线(Service Bus)的设计规范。
Queued Services
队列服务
1. On the client, always verify that the queue (and a dead-letter queue, when applicable) is available before calling the queued service. Use QueuedServiceHelper.VerifyQueues() for this purpose.
         在客户端,在调用队列服务以前,始终检查队列是否可用(如果可以的话,也包括确认死信队列)。使用QueuedServiceHelper.VerifyQueues()方法检查。
2. Always verify that the queue is available when hosting a queued service (this is done automatically by ServiceHost<T>).
         当托管队列服务的时候始终检查队列是否可用(ServiceHost<T>会自动检测)
3. Except in isolated scenarios, avoid designing the same service to work both queued and non-queued.
         除了某些单独的场景,避免避免在同一个服务里同时使用队列和非队列服务
4. The service should participate in the playback transaction.
         服务应该参与到回放事务中
5. When participating in the playback transaction, avoid lengthy processing in the queued service.
         当参与到回放事务里,避免队列服务里出现冗长的处理工作
6. Avoid sessionful queued services.
         避免使用会话性队列服务
7. When using a singleton queued service, use a volatile resource manager to manage the singleton state.
         当使用单例队列服务时,使用易失资源管理器去管理单例状态
8. When using a per-call queued service, explicitly configure the contract and the service to be per-call and sessionless:
         当使用单调队列服务时,明确设置服务和契约的单调和非回话属性
[ServiceContract(SessionMode = SessionMode.NotAllowed)]
interface IMyContract
{...}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
class MyService : IMyContract
{...}
9. Always explicitly set contracts on a queued singleton to disallow sessions:
         始终禁止在单例队列服务模式下使用会话
[ServiceContract(SessionMode = SessionMode.NotAllowed)]
interface IMyContract
{...}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
class MyService : IMyContract
{...}
10. The client should call a queued service inside a transaction.
         客户端应该在一个事务内部调用队列服务
11. On the client side, do not store a queued service proxy in a member variable.
         在客户端,不要在成员变量里存储队列服务的代理
12. Avoid relatively short values of TimeToLive, as they negate the justification for a queued service.
         避免使用相对短的TimeToLive值,因为这会干扰队列服务的决策
13. Avoid nontransactional queues.
         避免非事务性队列
14. When using a response queue, have the service participate in the playback transaction and queue the response in that transaction.
         当使用一个应答队列时,让服务参与到一个回放事务中,并且在事务里,把应答消息装入队列。
15. Have the response service participate in the response playback transaction.
         让应答服务参与到应答回放事务里
16. Avoid lengthy processing in a queued response operation.
         避免在应答操作里进行冗长的处理工作
17. With MSMQ 3.0, prefer a response service to a poison queue service dealing with failures of the service itself.
         对于MSMQ3.0,推荐使用应答服务来处理服务自身失败,而不是毒信队列
18. With MSMQ 4.0, use ReceiveErrorHandling.Reject for poison messages unless you have advanced processing with ReceiveErrorHandling.Move.
Avoid ReceiveErrorHandling.Fault and ReceiveErrorHandling.Drop.
         对于MSMQ4.0,除非对ReceiveErrorHandling.Move有高级处理,否则为毒信队列使用ReceiveErrorHandling.Reject,避免使用ReceiveErrorHandling.Fault 和 ReceiveErrorHandling.Drop
19. With MSMQ 4.0, consider the use of a response service to handle service playback failures.
         对于MSMQ4.0,考虑使用应答服务去处理服务回放错误
20. Unless dealing with a sessionful contract and service, never assume the order of queued calls.
         除非处理会话契约和服务,否则从不假定队列调用是有序的
21. Avoid multiple service endpoints sharing a queue.
         避免多个服务终结点共享一个队列
22. Avoid receive context.
         避免使用接收上下文环境
Security
安全
1. Always protect the message and provide for message confidentiality and integrity.
         始终保护消息,并为消息提供安全性和完整性
2. In an intranet, you can use Transport security as long as the protection level is set to EncryptAndSign.
         在企业网内,只要你把保护级别设置为EncryptAndSign你可以使用传输安全,
3. In an intranet, avoid impersonation. Set the impersonation level to TokenImpersonationLevel.Identification.
         在企业网内,避免使用impersonation,把impersonation 级别设置为TokenImpersonationLevel.Identification
4. When using impersonation, have the client use TokenImpersonationLevel.Impersonation.
         当使用impersonation时,让客户端使用TokenImpersonationLevel.Impersonation
5. Use the declarative security framework and avoid manual configuration.
         使用声明式安全框架,并避免手动配置
6. Never apply the PrincipalPermission attribute directly on the service class:
         从不在服务上直接设置PrincipalPermission属性
//Will always fail:
[PrincipalPermission(SecurityAction.Demand,Role = "...")]
public class MyService : IMyContract
{...}
7. Avoid sensitive work that requires authorization at the service constructor.
         避免在服务构造函数上,完成需要授权的工作
8. Avoid demanding a particular user, with or without demanding a role:
         避免要求一个特定的用户,不管是否要求的角色
//Avoid:
[PrincipalPermission(SecurityAction.Demand,Name = "John")]
public void MyMethod()
{...}
9. Do not rely on role-based security in the client’s callback operations.
         不要在客户端回调操作里依赖基于角色的安全
10. With Internet clients, always use Message security.
         对于Internet客户端,始终使用消息安全
11. Allow clients to negotiate the service certificate (the default).
         运行客户端与服务端进行证书协商(默认)
12. Use the ASP.NET providers for custom credentials.
         为自定义客户端凭据使用ASP.NET providers
13. When developing a custom credentials store, develop it as a custom ASP.NET provider.
         当开发自定义客户端凭据存储的时候,使用自定义ASP.NET provider.
14. Validate certificates using peer trust.
         使用对等信任验证证书
The Service Bus
服务总线
1. Prefer the TCP relay binding.
         推荐使用TCP Relay绑定
2. Make your services be discoverable.
         让你的服务是可以被发现
3. Do use discrete events.
         使用分离事件
4. Do not treat buffers as queues.
         不要把缓存当做队列
5. With buffers, avoid raw WCF messages and use the strongly typed, structured calls technique of BufferedServiceBusHost<T> and BufferedServiceBusClient<T>.
         对于缓存,避免原始的WCF消息以及使用强类型、结构化的BufferedServiceBusHost<T> 和 BufferedServiceBusClient<T>调用方法
6. Use message security.
         使用消息安全
7. Do not use service bus authentication for user authentication.
         不要是有服务总线验证去做用户验证的工作
8. Strive for anonymous calls and let the service bus authenticate the calling application.
         争取匿名调用,并且让服务总线验证调用程序

转载于:https://blog.51cto.com/frankxulei/318668

WCF服务编程设计规范(6):队列服务、安全和服务总线相关推荐

  1. WCF服务编程设计规范(9):中文、中英文对照、英文版资料共享下载

    这里我把所有的<WCF服务编程设计规范>这个系列的资料共享出来,包含<WCF编码规范>与<WCF最佳实践>的翻译手稿,提供中文.中英文对照.英文版资料共享Word与 ...

  2. WCF服务编程 学习笔记(1)

    你或许可以使用某一技术实现某些功能,可以按着指定的要求,完成特定的功能,实现某一想要的效果,这表示你可以使用该技术,会使用该技术,但是我们不能停留在使用的层次上,还要了解它们的运行机制,可能有点深了, ...

  3. 徐雷:做最好的自己!写在《mongodb实战》第2版和《WCF服务编程》第4版出版之际...

    做最好的自己:写在<mongodb实战>第2版和<WCF服务编程>第4版出版之际.很久之前我写过一个类似的文章. 这篇文章写给过去的10.也写给未来的自己. 你是否对自己的未来 ...

  4. WCF服务编程(4):《WCF服务编程》第3版中文版翻译结束,即将出版

    原文地址: <WCF服务编程>第4版本翻译完毕!2016年底应该出版 [置顶]↑ WCF服务编程(4):<WCF服务编程>第3版中文版翻译结束,即将出版 ↑ 作为世界范围内最经 ...

  5. WCF服务编程 学习笔记(2)

    (承接上文,只是不好意思,在文中用到的图片自己没有插入.) 12.终结点 服务与地址.绑定以及契约有关.其中,地址定义了服务的位置,绑定定义了服务通信的方式,契约则定义了服务的内容.为便于记忆,我们可 ...

  6. python3 socketserver模块 网络服务编程框架

    socket编程过于底层,编程虽然有套路,但是想要写出健壮的代码还是比较困难的,所以很多语言都对socket底层 API进行封装,Python的封装就是--socketserver模块.它是网络服务编 ...

  7. 工作流编程循序渐进(9:使用本地服务在宿主和工作流之间通信)

    工作流编程循序渐进(9:使用本地服务在宿主和工作流之间通信) 作者  朱先忠 [摘要]       在本篇中,首先详细分析本地服务有关概念,探讨本地服务在工作流运行时.工作流实例及工作流宿主间的地位及 ...

  8. 昨天终于收到《.Net Web服务编程》

    昨天终于收到<.Net Web服务编程>,在china-pub上买的,打开包装,这本书给我的第一感觉就是很清爽(我第一次买O'Reilly的书),虽然在网站上看到过这这本书的封面,不过见到 ...

  9. Atitit 面向对象编程(OOP)、面向组件编程(COP)、面向方面编程(AOP)和面向服务编程(SOP)的区别和联系...

    Atitit 面向对象编程(OOP).面向组件编程(COP).面向方面编程(AOP)和面向服务编程(SOP)的区别和联系 1. 面向组件编程(COP) 所以,组件比起对象来的进步就在于通用的规范的引入 ...

最新文章

  1. [JDK8] Stream
  2. Sharding-JDBC 1.3.0发布——支持读写分离
  3. Linux下安装配置NTP时间同步服务器
  4. 深入redis内部--初始化服务器
  5. php 旋转图片 并保存,如何在PHP中旋转并保存图像
  6. 初学 Ajax(涉及 php)
  7. 51系列计算机字长,计算机等级考试之MsOffice练习题第51套
  8. Java NIO学习篇之缓冲区Buffer详解
  9. java 并发存储,java并发编程——Java存储模型(JMM)
  10. cvtres.exe无法正常启动_启动盘介绍
  11. 红帽Redhat产品资料官方文档
  12. 2021牛客寒假算法基础集训营5,签到题BF
  13. 万能html5视频播放器安卓,XPlayer万能视频播放器
  14. ubuntu18使用wine安装TIM和微信
  15. Android开发好用的依赖库
  16. 你一定要掌握的三条IT运维面试技巧
  17. 数据库中COMMENT关键字的使用
  18. WPS表格恢复到指定日期版本(图片详解)
  19. uvalive 3713 2-sat
  20. android remoteviews view,Android 理解RemoteViews

热门文章

  1. 电脑cpu排名_可能是最详细的小白【笔记本电脑】选购攻略(附热门机型推荐)...
  2. python训练馆_Python训练营 01
  3. 安卓给string对象赋值_String 面试题!看完让你恍然大悟!
  4. h5压缩图片上传 php_一键压缩,图片上传大小不得超过200K?
  5. git--版本创建、回滚的原理及演练
  6. leetcode 378. Kth Smallest Element in a Sorted Matrix
  7. [Swift]LeetCode206. 反转链表 | Reverse Linked List
  8. 【Django】模型层说明
  9. 乌班图14.04安装搜狗输入法
  10. hibernate 管理 Session(单独使用session,非spring)