发布我的解决方案,万一有人需要算出这个
NetMSMQBinding
不支持,所以我用错了绑定从客户端设置消息的优先级。更强大的MsMqIntegrationBinding
是正确的选择。
客户端: 从客户端,需要简单地创建一个System.Messaging.Message
对象,设置优先级并将其放入指向目标MQ的MessageQueue.MessageQueue
对象中。
服务器端: 的WorkflowService
托管WCF项目需要在web.config以下endpointBinding:
<endpoint address="msmq.formatname:DIRECT=OS:.\private$\MyWebService/MyProcessingService.xamlx" binding="msmqIntegrationBinding" bindingConfiguration="MyMsMqIntegrationBinding" contract="IMyProcessingService" name="MqIntegrationBindingEndPoint" />
(地址是假设MQ服务是本地WCF托管)
<bindings> <!--We use msmqIntegrationBinding instead of netMsmqBinding since we want to control priority of MQ messages being dropped in the queue and that is not supported in netMsmq --> <msmqIntegrationBinding> <binding name="MyMsMqIntegrationBinding" exactlyOnce="false"> <security mode="None" /> </binding> </msmqIntegrationBinding>
从MQ并处理它是通过丢弃在XAMLX“接收”活动,并选择Message
的内容定义消息类型为System.ServiceModel.MsmqIntegrationMessage<YourTypeGoesHere>
现在,你必须从你的ActivityContext
访问此MsmqMessage<yourType>
收到MsmqMessage的方式,你可以检索该消息中发送的值。
这是构建一个可扩展的一个非常有用和强大的方式,节流优先控制MQ + WCF +基于WF Web服务
中不太支持使用它。没有** System.ServiceModel.MsmqIntegrationMessage **这样的事情。你的意思是** System.ServiceModel.MsmqIntegration.MsmqMessage **? –
MickyD
2014-04-17 04:19:49