發佈我的解決方案,萬一有人需要算出這個
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